Jump to content

Recommended Posts

<?php

if(isset($_POST['Submit'])) {

$name = $_POST['name'];

$tele = $_POST['tele'];

$email = $_POST['email'];

$comments = $_POST['comments'];

$mailing = $_POST['mailing'];

if($name == '' or $email == '' or $comments == '') {

$err = true;

$msg = 'Please complete all the required fields for us to be able to contact you.';

} else {

$mailmsg = 'OceanSafe WEBSITE MAIL:' . "\n\n";

$mailmsg.= 'Name: ' . $name . "\n";

$mailmsg.= 'Tele: ' . $tele . "\n";

$mailmsg.= 'Email: ' . $email . "\n";

$mailmsg.= 'Required: ' . $required . "\n";

if($mailing == 'true') {

$mailmsg.= 'Please add me to your mailing list to receive notice of offers from time to time';

}

if (eregi("\r",$email) || eregi("\n",$email)){

die ("spam!");

 

} else {

if(mail(email@domainname.co.uk,'OceanSafe - Web Enquiry Form', $mailmsg, "From: noreply@domainname.co.uk")) {

header("Location: validate.htm");

}

}

}

}

?>

 


and in th form


 

<form id="form2" method="post" action="contact.php">

  <div>

    <p align="center">

    <font size="2" face="Verdana">

    <label for="name">Full Name:*</label><br>

    <input name="name" type="text" class="text" id="name" value="<?php echo $name; ?>" size="45" /><br>

<label for="name">Daytime Contact Number:*</label><br>

    <input name="tele" type="text" class="text" id="tele" value="<?php echo $tele; ?>" size="45" /><br>

<label for="email">Your Email Address:*</label><br>

<input name="email" type="text" class="text" id="email" value="<?php echo $email; ?>" size="45" /><br>

<label for="comments">Work Required :*</label><br>

<textarea name="comments" cols="34" rows="2" class="text" id="comments"><?php echo $comments; ?></textarea><br>

<label for="mailing">Add me to your mailing list</label>

    <input type="checkbox" name="mailing" value="true" id="mailing" /><br>

<input name="Submit" type="submit" class="btn" value="SEND" />

</font>

</div>

</form>

 

I *think* you have error handling on either in your script or turned on for the server by default. Since the page has not been POSTed, the variables do not have a value and it is throwing the error. Try ensuring that the variables have been set first:

 

<?php

<?php

$name='';
$tele='';
$email='';
$comments='';
$mailing='';

if(isset($_POST['Submit'])) {
   $name = $_POST['name'];
   $tele = $_POST['tele'];
   $email = $_POST['email'];
   $comments = $_POST['comments'];
   $mailing = $_POST['mailing'];
   if($name == '' or $email == '' or $comments == '') {
      $err = true;
      $msg = 'Please complete all the required fields for us to be able to contact you.';
   } else {
      $mailmsg = 'OceanSafe WEBSITE MAIL:' . "\n\n";
      $mailmsg.= 'Name: ' . $name . "\n";
      $mailmsg.= 'Tele: ' . $tele . "\n";
      $mailmsg.= 'Email: ' . $email . "\n";
      $mailmsg.= 'Required: ' . $required . "\n";
      if($mailing == 'true') {
         $mailmsg.= 'Please add me to your mailing list to receive notice of offers from time to time';
      }
      if (eregi("\r",$email) || eregi("\n",$email)){
         die ("spam!");

      } else {
         if(mail(email@domainname.co.uk,'OceanSafe - Web Enquiry Form', $mailmsg, "From: noreply@domainname.co.uk")) {
            header("Location: validate.htm");
         }
      }
   }
}
?>

?>

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.