Hi,
I have a script for submitting a course booking form. When I submit the form it tells me that I have not submitted the following information: Managers Name and Managers Email - even though I have filled in all the fields.
I have gone over and over the script but can't seem to see where i am going wrong. Can anyone help me?
The code is as follows:
<?
include 'db.php';
// Define post fields into simple variables
$course_title = $_POST['course_title'];
$course_date = $_POST['course_date'];
$attendee_name = $_POST['attendee_name'];
$attendname = $_POST['manager_name'];
$manager_eee_email = $_POST['attendee_email'];
$manager_mail = $_POST['manager_email'];
$cost_centre = $_POST['cost_centre'];
$charge_code = $_POST['charge_code'];
/* strip some slashes in case the user entered
any escaped characters. */
$course_title = stripslashes($course_title);
$course_date = stripslashes($course_date);
$attendee_name = stripslashes($attendee_name);
$attendee_email = stripslashes($attendee_email);
$manager_name = stripslashes($manager_name);
$manager_email = stripslashes($manager_email);
$cost_centre = stripslashes($cost_centre);
$charge_code = stripslashes($charge_code);
/* Do some error checking on the form posted fields */
if((!$course_title) || (!$course_date) || (!$attendee_name) || (!$attendee_email) || (!$manager_name) || (!$manager_email) || (!$cost_centre) || (!$charge_code)){
echo 'You did not submit the following required information <br />';
if(!$course_title){
echo "The title of the course you wish to attend";
}
if(!$course_date){
echo "The date of the course you wish to attend";
}
if(!$attendee_name){
echo "Your Name";
}
if(!$attendee_email){
echo "Your e-mail address";
}
if(!$manager_name){
echo "Your managers name";
}
if(!$manager_email){
echo "Your managers e-mail";
}
if(!$cost_centre){
echo "Cost Centre Number";
}
if(!$charge_code){
echo "Charge Code";
}
echo'<a href="javascript:self.close();">Close Window</a>';
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
// Enter info into the Database.
$sql = mysql_query("INSERT INTO users (course_title, course_date, attendee_name, attendee_email, manager_name, manager_email, cost_centre, charge_code)
VALUES('$course_title', '$course_date', '$attendee_name', '$attendee_email', '$manager_name', '$manager_email', '$cost_centre', '$charge_code')"
or die (mysql_error());
if(!$sql){
echo 'There has been an error submitting your form. Please contact <a>mailto:me@company.com</a>';
} else {
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "OUP Course Booking";
$message =
"$attendee_name has requested a place on:
$course_title
$course_date
Manager Details:
$manager_name
$manager_email";
mail("$attendee_email", $subject, $message, "From: Company Name<me@company.com>\nX-Mailer: PHP/" . phpversion());
echo 'Your booking form has been sent';
echo 'Confirmation of your booking will be emailed to you shortly';
}
?>
</body>
</html>
ps. I have checked that all the fields in my form are named correctly!!
Thankyou in advance . . .
I have a script for submitting a course booking form. When I submit the form it tells me that I have not submitted the following information: Managers Name and Managers Email - even though I have filled in all the fields.
I have gone over and over the script but can't seem to see where i am going wrong. Can anyone help me?
The code is as follows:
<?
include 'db.php';
// Define post fields into simple variables
$course_title = $_POST['course_title'];
$course_date = $_POST['course_date'];
$attendee_name = $_POST['attendee_name'];
$attendname = $_POST['manager_name'];
$manager_eee_email = $_POST['attendee_email'];
$manager_mail = $_POST['manager_email'];
$cost_centre = $_POST['cost_centre'];
$charge_code = $_POST['charge_code'];
/* strip some slashes in case the user entered
any escaped characters. */
$course_title = stripslashes($course_title);
$course_date = stripslashes($course_date);
$attendee_name = stripslashes($attendee_name);
$attendee_email = stripslashes($attendee_email);
$manager_name = stripslashes($manager_name);
$manager_email = stripslashes($manager_email);
$cost_centre = stripslashes($cost_centre);
$charge_code = stripslashes($charge_code);
/* Do some error checking on the form posted fields */
if((!$course_title) || (!$course_date) || (!$attendee_name) || (!$attendee_email) || (!$manager_name) || (!$manager_email) || (!$cost_centre) || (!$charge_code)){
echo 'You did not submit the following required information <br />';
if(!$course_title){
echo "The title of the course you wish to attend";
}
if(!$course_date){
echo "The date of the course you wish to attend";
}
if(!$attendee_name){
echo "Your Name";
}
if(!$attendee_email){
echo "Your e-mail address";
}
if(!$manager_name){
echo "Your managers name";
}
if(!$manager_email){
echo "Your managers e-mail";
}
if(!$cost_centre){
echo "Cost Centre Number";
}
if(!$charge_code){
echo "Charge Code";
}
echo'<a href="javascript:self.close();">Close Window</a>';
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
// Enter info into the Database.
$sql = mysql_query("INSERT INTO users (course_title, course_date, attendee_name, attendee_email, manager_name, manager_email, cost_centre, charge_code)
VALUES('$course_title', '$course_date', '$attendee_name', '$attendee_email', '$manager_name', '$manager_email', '$cost_centre', '$charge_code')"
if(!$sql){
echo 'There has been an error submitting your form. Please contact <a>mailto:me@company.com</a>';
} else {
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "OUP Course Booking";
$message =
"$attendee_name has requested a place on:
$course_title
$course_date
Manager Details:
$manager_name
$manager_email";
mail("$attendee_email", $subject, $message, "From: Company Name<me@company.com>\nX-Mailer: PHP/" . phpversion());
echo 'Your booking form has been sent';
echo 'Confirmation of your booking will be emailed to you shortly';
}
?>
</body>
</html>
ps. I have checked that all the fields in my form are named correctly!!
Thankyou in advance . . .