Jump to content

email not sent on post data/ submit button


diasansley

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.