我对ajaxform有问题。
<?php
session_start();
$random_number = rand(1,9).rand(1,9).rand(1,9).rand(1,9).rand(1,9).rand(1,9);
$_SESSION['captcha_text'] = $random_number;
$captcha_image = imagecreatefromjpeg("captcha.jpg");
$font_color = imagecolorallocate($captcha_image, 0, 0, 0);
imagestring($captcha_image, 5, 20, 5, $random_number, $font_color);
imagejpeg($captcha_image);
imagedestroy($captcha_image);
?>
我有另一个php文件,名为pro。它在动作表单上执行,并发送一封包含表单数据的电子邮件:
<?php
session_start();
@extract($_POST);
$sub = "Curriculum di: ".stripslashes($name);
$message = stripslashes($messaggio);
$fromail = stripslashes($email);
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
$filename = $_FILES['file']['name'];
$boundary =md5(date('r', time()));
$headers = "From: ".$fromail;
$headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
$message="This is a multi-part message in MIME format.
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
$message
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--_1_$boundary--";
if(isset($_POST['txtCaptcha']) and $_POST['txtCaptcha'] !='')
if($_SESSION['captcha_text'] == $_POST['txtCaptcha'])
mail('myemail@myemail.it', $sub, $message, $headers);
?>
现在,如果电子邮件发送正确与否,我想显示一个警报:
<script>
$(document).ready(function() {
$('#myFormId').ajaxForm(function() {
//Instructions to enter
});
});
</script>