Excellent
07-08-2008, 02:45 PM
Hey theres a few about but a lot of people want to know how to make an application form, heres the code, I have used comments to show you what to do.
<?php
if(isset($_POST['send'])) { //Checks if the applicant has submitted the form.
if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.
echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
} //End the check on the fields.
else //Maybe..
{
$email = addslashes(htmlspecialchars($_POST['email'])); //Removes the slashes.
$name = addslashes(htmlspecialchars($_POST['name']));
$sub = addslashes(htmlspecialchars($_POST['sub']));
$job = addslashes(htmlspecialchars($_POST['job']));
$mail = "[email protected]"; //Change this to the the email you want the message to go to.
$from = "$name,$job"; //Displays the applicants name and the job they want.
$subject = "$name has applied for the $job!"; //Displays the name and the job in the email subject.
$msg = "Heres their details:<br><br>
$email, $name, $job<br><br>$msg"; //The users message.
mail("$mail","$from","$subject","$msg"); //We use the mail(); function to send the email.
echo "Your application has been sent, we will reply within 2-3 working days!"; //Hooharr! Success!
} //End the else.
} // End the post.
else //Form time!
{
echo "<form method='post' action='$_SERVER[PHP_SELF]'>
Email:<br>
<input type='text' name='email' size='30'><br>
Name:<br>
<input type='text' name='name' size='30'><br>
Job:<br>
<select name='job' size='1'>
<option value='Radio manager' value='Radio manager'>Radio manager</option>
<option value='DJ' value='DJ'>DJ</option>
<option value='News team' value='News team'>News team</option>
<option value='Graphics team' value='Graphics team'>Graphics team</option>
<option value='Forum MOD' value='Forum MOD'>Forum MOD</option>
<option value='Alterations team' value='Alterations team'>Alterations team</option>
</select><br>
Message:<br>
<textarea name='sub' cols='45' rows='6'></textarea><br>
<input type='submit' name='send' value='Submit'></form>";
//You can change these values or whatever, have fun.
} //End the last else.
?>
<?php
if(isset($_POST['send'])) { //Checks if the applicant has submitted the form.
if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.
echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
} //End the check on the fields.
else //Maybe..
{
$email = addslashes(htmlspecialchars($_POST['email'])); //Removes the slashes.
$name = addslashes(htmlspecialchars($_POST['name']));
$sub = addslashes(htmlspecialchars($_POST['sub']));
$job = addslashes(htmlspecialchars($_POST['job']));
$mail = "[email protected]"; //Change this to the the email you want the message to go to.
$from = "$name,$job"; //Displays the applicants name and the job they want.
$subject = "$name has applied for the $job!"; //Displays the name and the job in the email subject.
$msg = "Heres their details:<br><br>
$email, $name, $job<br><br>$msg"; //The users message.
mail("$mail","$from","$subject","$msg"); //We use the mail(); function to send the email.
echo "Your application has been sent, we will reply within 2-3 working days!"; //Hooharr! Success!
} //End the else.
} // End the post.
else //Form time!
{
echo "<form method='post' action='$_SERVER[PHP_SELF]'>
Email:<br>
<input type='text' name='email' size='30'><br>
Name:<br>
<input type='text' name='name' size='30'><br>
Job:<br>
<select name='job' size='1'>
<option value='Radio manager' value='Radio manager'>Radio manager</option>
<option value='DJ' value='DJ'>DJ</option>
<option value='News team' value='News team'>News team</option>
<option value='Graphics team' value='Graphics team'>Graphics team</option>
<option value='Forum MOD' value='Forum MOD'>Forum MOD</option>
<option value='Alterations team' value='Alterations team'>Alterations team</option>
</select><br>
Message:<br>
<textarea name='sub' cols='45' rows='6'></textarea><br>
<input type='submit' name='send' value='Submit'></form>";
//You can change these values or whatever, have fun.
} //End the last else.
?>