MP145 Posted November 14, 2008 Share Posted November 14, 2008 I have this contact form that uses phpmailer, added captcha and some validation but when i click submit - Nothing Happens. I am not very sure what is wrong, some pointers please. <?php function validate_email($email){ $exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$"; if(eregi($exp,$email)){ if(checkdnsrr(array_pop(explode("@",$email)),"MX")){ return true; }else{ return false; } }else{ return false; } } if (isset($_POST['Submit'])) { if (empty($_POST['nama'])) { $errors[] = 'Please enter a name'; } if (empty($_POST['email'])) { $errors[] = 'Please enter an e-mail'; } else if (!validate_email($_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } if (empty($_POST['mesaj'])) { $errors[] = 'Please enter some comments'; } if (empty($_POST['validator'])) { $errors[] = 'Please enter security code'; } else if ($_POST['validator'] != $_SESSION['rand_code']) { $errors[] = 'Please enter correct security code'; } if (count($errors) == 0) { $RepName = $_POST["nama"]; $RepMail = $_POST["email"]; $RepCom = $_POST["mesaj"]; require("./phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "XXXXX"; $mail->SMTPAuth = true; $mail->Username = "XXXX"; $mail->Password = "XXXX"; $mail->From = "$RepMail"; $mail->FromName = "$RepName"; $mail->AddAddress("XXXXXX", "Web Contact"); $mail->AddReplyTo("ReplyEmail", "ReplyName"); $mail->IsHTML(true); $mail->Subject = "Contact Request"; $mail->Body = "Mail was sent recently<br> $RepCom <br><br> Call urgent : $urgent <br><br> Call Back : $call <br><br>Regards : <br>WebMaster"; $mail->WordWrap = 50; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; } else { echo $errors[0]; } } ?> <br /><br /> <form action="" method="post"> <table width=70% cellspacing="0"> <tr> <td>Your Name :</td> <td><input name="nama" type="text" id="nama" size="40" maxlength="255" class="inputs" onfocus="this.className='inputs-focus';" onblur="this.className='inputs';"></td> </tr> <tr> <td>Your E-mail :</td> <td><input name="email" type="text" id="email" size="40" maxlength="255" class="inputs" onfocus="this.className='inputs-focus';" onblur="this.className='inputs';"></td> </tr> <tr> <td valign="top">Comments :</td> <td> <textarea name="mesaj" cols="37" rows="5" id="mesaj" class="inputs" onfocus="this.className='inputs-focus';" onblur="this.className='inputs';"></textarea></td> </tr> <tr> <td>Security Code :</td> <td height="40px" valign="middle"><input name="validator" type="text" id="validator" size="5" maxlength="5" class="inputs" onfocus="this.className='inputs-focus';" onblur="this.className='inputs';"> <img src="random.php" alt="CAPTCHA image" width="60" height="20" vspace="1"></td> </tr> </table> <p align="center"> <input name="Submit" type="button" value="Submit"> <input type="button" name="Reset" value="Reset" onclick="this.form.reset();return false;"> </p> </form> </center> Link to comment https://forums.phpfreaks.com/topic/132729-solved-submit-button-and-form-validation-is-not-functioning/ Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 submit button isn't a submit button <input name="Submit" type="button" value="Submit"> should be <input name="Submit" type="submit" value="Submit"> Link to comment https://forums.phpfreaks.com/topic/132729-solved-submit-button-and-form-validation-is-not-functioning/#findComment-690242 Share on other sites More sharing options...
MP145 Posted November 14, 2008 Author Share Posted November 14, 2008 YESSS, thank you so much rhodesa Link to comment https://forums.phpfreaks.com/topic/132729-solved-submit-button-and-form-validation-is-not-functioning/#findComment-690278 Share on other sites More sharing options...
MP145 Posted November 14, 2008 Author Share Posted November 14, 2008 Works like a charm now.. and i forgot to add session_start(); at the top of the page. ) Link to comment https://forums.phpfreaks.com/topic/132729-solved-submit-button-and-form-validation-is-not-functioning/#findComment-690281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.