THE HTML FORM; form.html
<form name="myform" action="process.php" method="POST">
<input type="hidden" name="check_submit" value="1" />
Name: <input type="text" name="Name" /><br />
From: <input type="text" name="from" /><br />
Select something from the list: <select name="Seasons">
<option value="Spring" selected="selected">Spring</option>
<option value="Summer">Summer</option>
<option value="Autumn">Autumn</option>
<option value="Winter">Winter</option>
</select><br /><br />
Choose one:
<input type="radio" name="Country" value="USA" /> USA
<input type="radio" name="Country" value="Canada" /> Canada
<input type="radio" name="Country" value="Other" /> Other
<br />
Choose the colors:
<input type="checkbox" name="Colors[]" value="green" checked="checked" /> Green
<input type="checkbox" name="Colors[]" value="yellow" /> Yellow
<input type="checkbox" name="Colors[]" value="red" /> Red
<input type="checkbox" name="Colors[]" value="gray" /> Gray
<br /><br />
Comments:<br />
<textarea name="Comments" rows="10" cols="60">Enter your comments here</textarea><br />
<input type="submit" name="submit" value="submit"/>
</form>
process.php
<?php
//Check whether the form has been submitted
if (array_key_exists('submit', $_POST)) {//the submit button was named submit, unless you changed it?
//Converts the new line characters (\n) in the text area into HTML line breaks (the <br /> tag)
$_POST['Comments'] = nl2br($_POST['Comments']);
//Check whether a $_GET['Languages'] is set<-Your not checking a $_GET
if ( isset($_POST['Colors']) ) {
//your just putting all the Array values into one key here, so still an array really...
$_POST['Colors'] = implode(', ', $_POST['Colors']); //Converts an array into a single string
}
//So your echoing the details being submitted, fine...
//Let's now print out the received values in the browser
echo "Your name: {$_POST['Name']}<br />";
echo "from: {$_POST['from']}<br />";
echo "Your favourite season: {$_POST['Seasons']}<br /><br />";
echo "Your comments:<br />{$_POST['Comments']}<br /><br />";
echo "You are from: {$_POST['Country']}<br />";
echo "Colors you chose: {$_POST['Colors']}<br />";
//pop the mail function here, set the headers and send
mail("info@youremail.com", 'online form',$comments,"from: $from");
} else {
//have the error handler here so that you keep traffic, and nothing is more annoying than a static
//error message really?
header("location: form.html");
exit; //kill the script here so that nothing else can be invoked by php... always handy
}
?>
well, i uploaded the form to a server. the sending process works well but the big problem is that it doesnt pick the details from the from. an empty email is sent to the recipient mail.
could anyone program the form according to his/her knowledge so that it picks the form details?