Notice: Undefined variable:
Hi,
I have an issue with a simple PHP email form on my website, which worked prior to us moving website host, but is now only partially sending information through via email.
It was recommended that I turned on error messaging to diagnose the problem(s) which I did.
The error which is repeated is: -
Notice: Undefined variable: first_lot_number in /var/www/vhosts/sheffieldauctiongallery.com/httpdocs/verify.php on line 207
Here is my code: -
Code:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "emailaddressremoved";
$email_subject = "subjectremoved";
ini_set('display_errors',1);
error_reporting(E_ALL);
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['auctiondate']) ||
!isset($_POST['forename']) ||
!isset($_POST['surname']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['address']) ||
!isset($_POST['agreement'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$auctiondate = $_POST['auctiondate']; // required
$forename = $_POST['forename']; // required
$surname = $_POST['surname']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$address = $_POST['address']; // required
$agreement = $_POST['agreement']; // required
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$forename)) {
$error_message .= 'The forename you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$surname)) {
$error_message .= 'The surname you entered does not appear to be valid.<br />';
}
if(strlen($address) < 2) {
$error_message .= 'The Address you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string)
{
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Date of Auction: ".clean_string($auctiondate)."\n";
$email_message .= "Conditions of Sale: ".clean_string($agreement)."\n";
$email_message .= "First Lot Number: ".clean_string($first_lot_number)."\n";
$email_message .= "Description: ".clean_string($first_lot_description)."\n";
$email_message .= "Max Bid in GBP, excl premium: ".clean_string($first_lot_bid)."\n\n";
$email_message .= "Second Lot Number: ".clean_string($second_lot_number)."\n";
$email_message .= "Description: ".clean_string($second_lot_description)."\n";
$email_message .= "Max Bid in GBP, excl premium: ".clean_string($second_lot_bid)."\n\n";
$email_message .= "Third Lot Number: ".clean_string($third_lot_number)."\n";
$email_message .= "Description: ".clean_string($third_lot_description)."\n";
$email_message .= "Max Bid in GBP, excl premium: ".clean_string($third_lot_bid)."\n\n";;
$email_message .= "Forth Lot Number: ".clean_string($forth_lot_number)."\n";
$email_message .= "Description: ".clean_string($forth_lot_description)."\n";
$email_message .= "Max Bid in GBP, excl premium: ".clean_string($forth_lot_bid)."\n\n";
$email_message .= "Fifth Lot Number: ".clean_string($fifth_lot_number)."\n";
$email_message .= "Description: ".clean_string($fifth_lot_description)."\n";
$email_message .= "Max Bid in GBP, excl premium: ".clean_string($fifth_lot_bid)."\n\n";
$email_message .= "Sixth Lot Number: ".clean_string($sixth_lot_number)."\n";
$email_message .= "Description: ".clean_string($sixth_lot_description)."\n";
$email_message .= "Max Bid in GBP, excl premium: ".clean_string($sixth_lot_bid)."\n\n";
$email_message .= "Seventh Lot Number: ".clean_string($seventh_lot_number)."\n";
$email_message .= "Description: ".clean_string($seventh_lot_description)."\n";
$email_message .= "Max Bid in GBP, excl premium: ".clean_string($seventh_lot_bid)."\n\n";
$email_message .= "Eighth Lot Number: ".clean_string($eighth_lot_number)."\n";
$email_message .= "Description: ".clean_string($eighth_lot_description)."\n";
$email_message .= "Max Bid in GBP, excl premium: ".clean_string($eighth_lot_bid)."\n\n";
$email_message .= "Forename: ".clean_string($forename)."\n";
$email_message .= "Surname: ".clean_string($surname)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Address: ".clean_string($address)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
If you are successful an email will be sent to you following the auction. Sale results will be uploaded to the catalogue after the auction. Please feel free to browse the rest of our website.
<?php
}
?>
I have highlighted the line in question in red
I hope someone can help, please! :confused:
Kind regards