diasansley Posted January 27, 2011 Share Posted January 27, 2011 hi guys i have a problem my mail dosent send if some data is entered in the textbox. if data is there it says page not found. If no data and i say submit it submits the same page and a blank email is sent. the form is used in the middle of the entire page. <form name="enquiry" action="<?php echo get_bloginfo('wpurl') .'/home/' ?>" method="POST" id="enquiry" > <div id="registerrow"> <div id="texttitle">Naam:</div> <input type="text" class="textboxdiv" name="name" id="name"> </div> <div id="registerrow"> <div id="texttitle">Email:</div> <input type="text" class="textboxdiv" name="email" id="email"> </div> <div id="registerrow"> <div id="texttitle">Telefoonnr.:</div> <input type="text" class="textboxdiv" name="phone" id="phone"> </div> <div id="registerrow"> <div id="texttitle">KvK nr.:</div> <input type="text" class="textboxdiv" name="kvknr" id="kvknr"> </div> <input name="Submit" type="submit" id="btnregister" /> </form> <?php include_once('mail_class.php'); require_once('mail_class.php'); if ($_POST['Submit']){ $name = $_POST['name']; $phone = $_POST['phone']; $msga = $_POST['kvknr']; $to = "nrocks@gmail.com"; $subject = "Enquiry for infosites"; $mailmsg = "<table width='772' border='2' cellpadding='0' bordercolor='#0099FF'>"; $mailmsg .= "<tr bgcolor='#0099FF'>"; $mailmsg .= "<td height='34' colspan='2' bgcolor='#91C8FF'><p align='center' style='font-family: Georgia, 'Times New Roman', Times, serif; font-size: 14pt;font-weight: bold;'><strong>Enquiry Form</strong></p></td>"; $mailmsg .= "</tr>"; $mailmsg .= "<tr>"; $mailmsg .= "<td height='38'><span style='font-family: Georgia, 'Times New Roman', Times, serif; font-weight: bold'><strong>Name:</strong></span></td>"; $mailmsg .= "<td height='38' > $name </td>"; $mailmsg .= "</tr>"; $mailmsg .= "<tr>"; $mailmsg .= "<td height='38'><span style='font-family: Georgia, 'Times New Roman', Times, serif; font-weight: bold'><strong>Phone No:</strong></span></td>"; $mailmsg .= "<td height='38' > $phone </td>"; $mailmsg .= "</tr>"; $mailmsg .= "<tr>"; $mailmsg .= "<td height='43'><span style='font-family: Georgia, 'Times New Roman', Times, serif; font-weight: bold'><strong>Enquiry For:</strong></span></td>"; $mailmsg .= "<td height='43'><span style='font-family: Georgia, 'Times New Roman', Times, serif; font-weight: bold'> $enquiry </span></td>"; $mailmsg .= "</tr>"; $mailmsg .= "<tr bgcolor='#0099FF'>"; $mailmsg .="<td height='35' colspan='2' bgcolor='#91C8FF'><p align='center' class='style1'> </p></td>"; $mailmsg .="</tr>"; $mailmsg .="</table>"; $headers = "From: ".$_POST['email']."\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; if (mail($to , $subject , $mailmsg, $headers)) { echo 'Mail Send Succesfully'; } else { echo 'Mail was not send, Try again'; } } ?> </div> thanks Quote Link to comment https://forums.phpfreaks.com/topic/225816-email-not-sent-on-post-data-submit-button/ Share on other sites More sharing options...
$php_mysql$ Posted January 27, 2011 Share Posted January 27, 2011 try if (isset($_POST['Submit'])) { } Quote Link to comment https://forums.phpfreaks.com/topic/225816-email-not-sent-on-post-data-submit-button/#findComment-1165886 Share on other sites More sharing options...
spaceman12 Posted January 27, 2011 Share Posted January 27, 2011 foreach ($_POST as $value) { if(!empty($value)) { //your code } else echo "Please fill in your infos"; } Quote Link to comment https://forums.phpfreaks.com/topic/225816-email-not-sent-on-post-data-submit-button/#findComment-1165892 Share on other sites More sharing options...
diasansley Posted January 27, 2011 Author Share Posted January 27, 2011 the isset dosent work!!! and when the data is entered in the text box pt says page not found. if no data an empty mail is sent. Kindly advice Thanks Quote Link to comment https://forums.phpfreaks.com/topic/225816-email-not-sent-on-post-data-submit-button/#findComment-1165904 Share on other sites More sharing options...
BlueSkyIS Posted January 27, 2011 Share Posted January 27, 2011 don't use if (isset($_POST['Submit'])) { check if the form was submitted, period. if ($_SERVER['REQUEST_METHOD'] == "POST") { then you don't have to worry about mis-spelling or mis-capitalizing variable names, and you'll also capture the case where the user hits return while in a field, submitting the form. Quote Link to comment https://forums.phpfreaks.com/topic/225816-email-not-sent-on-post-data-submit-button/#findComment-1165989 Share on other sites More sharing options...
diasansley Posted January 28, 2011 Author Share Posted January 28, 2011 hi BlueSkyIS i tried what u gave me but still only when there is no data in the textbox the mail is sent. Once i enter some data and click submit it says page not found. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/225816-email-not-sent-on-post-data-submit-button/#findComment-1166436 Share on other sites More sharing options...
cyberRobot Posted January 28, 2011 Share Posted January 28, 2011 When submitting the form, does the URL change when you enter data vs leaving the field blank? In other words, when you hit the submit button in both senerios does the URL stay the same? Is this form on a WordPress website? If so, you may want to also ask the WordPress forum: http://wordpress.org/support/ Note that I'm not very familiar with WordPress yet. I have attempted to do some PHP things with WordPress that work for a "normal" website, but for whatever reason they didn't work in the WordPress environment. Quote Link to comment https://forums.phpfreaks.com/topic/225816-email-not-sent-on-post-data-submit-button/#findComment-1166525 Share on other sites More sharing options...
diasansley Posted January 28, 2011 Author Share Posted January 28, 2011 i put the form action as a another page!!! thats it nothin else, i have pasted my code above! Quote Link to comment https://forums.phpfreaks.com/topic/225816-email-not-sent-on-post-data-submit-button/#findComment-1166530 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.