<?php
$first =  $_POST['first'];
$last =  $_POST['last'];
$email =  $_POST['email'];
$phone =  $_POST['phone'];
$Submit = $_POST['Submit'];
$first = strtolower($first);
$last = strtolower($last);
$first=ucfirst($first);
$last=ucfirst($last);
$general = " <br> Please try again ! ";
$no_first = "  your first name, please... ";
$no_last = " your last name, please..... ";
$no_phone = " a contact number (we won't pester you, we're too busy!..... ";
$no_email = "  E-mail address?....";
$error = 0;
     if ($email =="")
      {
       $error = $error +1;
       $message = $message.$no_email;
       $set_email = 1;
       }
 if ($email <> "" and !ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", "$email"))
 {
 $error = $error +1;
 $message = $message.$no_first;
 }
 if ($last =="")
 {
 $error = $error +1;
 $message = $message.$no_last;
 }
  if ($phone =="")
 {
 $error = $error +1;
 $message = $message.$no_phone;
 }
if($error ==0 and $Submit=="Submit")
          {
echo "Thank you $first for your enquiry.";
  $mail_subject = "Enquiry";
  $mail_message = " Name $first $last
  email:
  $email
phone:
$phone
 Requires more details about $type_prop:
 Ref: $ref Price: $price
 Comments: $comments
 In $complex at $location
 IP: $ip
 ";
  $mail_from = "From:$email";
 $Email = "info@t.com";
  if(mail($Email, $mail_subject, $mail_message, $mail_from));
$mail_subject = "enquiry";
$mail_boundry = md5(uniqid(""));
$mail_headers .= "From:info@t.com\r\n";
$mail_headers .= "MIME-Version: 1.0\r\n";
$mail_headers .= "Content-Type: multipart/alternative;\r\n";
$mail_headers .= "               boundary=\"$mail_boundry\"\r\n";

$mail_message = "This is a multi-part message in MIME format.

--$mail_boundry
Content-Type: text/plain; charset=\"US-ASCII\"
 Content-Transfer-Encoding: 7bit
Dear $first,<br><br>Thank you very much for your enquiry
--$mail_boundry
Content-Type: text/html; charset=\"US-ASCII\"
 Content-Transfer-Encoding: 7bit

<html>
<head>
<style type =\"text/css\">
.norm {
 font-family: Verdana, Arial, Helvetica, sans-serif;
 font-size: 12px;
 font-weight: normal;
 color: #000000;
}
a:link {
 font-family: Verdana, Arial, Helvetica, sans-serif;
 font-size: 12px;
 font-weight: normal;
 color: blue;
 text-decoration: underline;
}
</style>
</head>
<body>
<table width=\"75%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\"><tr><td><tr><td class=\"norm\"><br>Dear $first,<br><br><br>Thank you very much for your enquiry</td></tr><tr></table>
--$mail_boundry--";
$Email = $email;
if(mail($Email, $mail_subject, $mail_message, $mail_headers));
 } 
else 
{
if($error >0 and $Submit=="Submit")
          {
echo "$message $general <br>";
}
echo "<form name=\"form1\" ACTION=\"$_SERVER[PHP_SELF]?prop_id=$prop_id\" METHOD=\"POST\" >Your First Name <br><br><input name=\"first\" value = \"$first\" type=\"text\" id=\"first\" size=\"25\"><br><br> Last Name<br><br><input name=\"last\" value = \"$last\" type=\"text\" id=\"last\" size=\"25\"><br><br>Email<br><br><input name=\"email\" value = \"$email\" type=\"text\" id=\"email\" size=\"25\"><br><br>Telephone Number<br><br><input name=\"phone\" value = \"$phone\" type=\"text\" id=\"phone\" size=\"25\"><br><br>
 <label for=\"comments\">Comments</label><textarea name=\"comments\" cols=\"18\" rows=\"4\" class=\"txt\" id=\"comments\"></textarea><br><br><div style=\"visibility:hidden\"><input name=\"email2\" type=\"text\" size=\"45\" id=\"email2\" > </div><input type=\"submit\" name=\"Submit\" value=\"Submit\" class=\"tpc4\">
</form>\n";
}
?>

Please can you help I have this code which works correctly and submits the info but it is showing undefined index for first,last,email,phone,submit

The indexes in the $_POST array on lines 2 - 6 are undefined until the form has been submitted.

You could replace each line with:

$first = isset($_POST['first']) ? $_POST['first'] : null;
$last = isset($_POST['last']) ? $_POST['last'] : null;
$email = isset($_POST['email']) ? $_POST['email'] : null;
$phone = isset($_POST['phone']) ? $_POST['phone'] : null;
$Submit = isset($_POST['Submit']) ? $_POST['Submit'] : null;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.