Page 1 of 1

PHP Code Problem

Posted: Fri Feb 19, 2010 10:28 am
by gjcluttrell
First of all I'm new to php & am still learning so there is probably errors I can't see in my code. I have it attached for you to look at. This code is supposed to allow a user to go to it in a browser & choose their name & click the submit button, & an email will be sent to them with data from the mysql database in it. For instance, if user Jane Doe chooses her name & clicks submit, she will get an email with the name, date_of_training_start, etc in it. Those are the names of the fields in the mysql database. PLEASE HELP!!! Thanks



<?php
if(isset($_POST['Submit'])) {
switch($_POST['name']) {
case "Jane Doe":
$email = "janedoe@google.com";
break;
case "John Doe":
$email = "johndoe@mail.com";
break;
case "Baby Doe";
$email = "babydoe@mail.com";
break;
default:
echo "Error, no supervisor selected!!!";
$failed = '1';
break;
}

if($failed != '1') {
$message = "office : {$_POST['name']}\nname : {$_POST['date_of_training_start']}\ndate : {$_POST['date_of_training_end']}\ndate : {$_POST['training_name']}\ntraining name : {$_POST['training_type']}\ntraining type : {$_POST['hours']}\hours :";
echo $message;
}
}
?>
<html>
<head>
<title>Email</title>
</head>
<body>
<form action="Posting_Code.php" method="post">
<b>Your Name:<br /></b>
<select name="name">
<option value=""></option>
<option value="Jane Doe">Jane Doe</option>
<option value="John Doe">John Doe</option>
<option value="Baby Doe">Baby Doe</option>
</select>
<br />
<br />
<br />
<input type="submit" name="Submit" value="Click Here to Have Your Training Information Emailed to You" />
</form>
<p> To return to our home page <a href="http://156.125.44.115/tnep">click here</a>.</p>
<p>To enter more training <a href="http://tnep-g-netadmin/code.php">click here</a>.</p>
</body>
</html>

Re: PHP Code Problem

Posted: Fri Feb 19, 2010 12:29 pm
by requinix
And what do you want us to do, exactly? You having a problem? Or are you looking for a critique?