Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem when submitting form

Status
Not open for further replies.

skootz

Technical User
Jan 22, 2003
11
0
0
GB
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 &quot;The title of the course you wish to attend&quot;;
}
if(!$course_date){
echo &quot;The date of the course you wish to attend&quot;;
}
if(!$attendee_name){
echo &quot;Your Name&quot;;
}
if(!$attendee_email){
echo &quot;Your e-mail address&quot;;
}
if(!$manager_name){
echo &quot;Your managers name&quot;;
}
if(!$manager_email){
echo &quot;Your managers e-mail&quot;;
}
if(!$cost_centre){
echo &quot;Cost Centre Number&quot;;
}
if(!$charge_code){
echo &quot;Charge Code&quot;;
}
echo'<a href=&quot;javascript:self.close();&quot;>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(&quot;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')&quot;) 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 = &quot;OUP Course Booking&quot;;
$message =

&quot;$attendee_name has requested a place on:
$course_title
$course_date

Manager Details:
$manager_name
$manager_email&quot;;

mail(&quot;$attendee_email&quot;, $subject, $message, &quot;From: Company Name<me@company.com>\nX-Mailer: PHP/&quot; . 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 . . .
 
Thanx for your reply Ian.

I have now fixed the problem and my stress levels are slowly going down!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top