I have a problem with ajaxform. I have a php file called captcha.php that it generates a captcha:
<?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);
?>
I have another php file called pro.php that it is executed on action form and send an e-mail with form's data:
<?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 .= "
MIME-Version: 1.0
Content-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);
?>
Now I would like to show an alert if the email was sent correctly or not:
<script>
$(document).ready(function() {
$('#myFormId').ajaxForm(function() {
//Instructions to enter
});
});
</script>
What's the solution? (Sorry for my bad english)