Topic: [TUTORIAL] How to make a simple contact form

Hello,

In this tutorial you will learn how to make a simple contact form:

<?php
if(isset($_POST['submit'])) {
 

$to = "you@you.com";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$option = $_POST['radio'];
$dropdown = $_POST['drop_down'];
 
foreach($_POST['check'] as $value) {

$check_msg .= "Checked: $value\n";

}
 
$body = "From: $name_field\n E-Mail: $email_field\n $check_msg Option: $option\n Drop-Down: $dropdown\n Message:\n $message\n";
 
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
 

} else {
?>

<form method="POST" action="mailer.php">
Name:
<input type="text" name="name" size="19"><br>
<br>
E-Mail:
<input type="text" name="email" size="19"><br>
<br>
 
<input type="checkbox" name="check[]" value="blue_color"> Blue<br>
<input type="checkbox" name="check[]" value="green_color"> Green<br>
<input type="checkbox" name="check[]" value="orange_color"> Orange<br>
<br>
<input type="radio" value="yes" name="radio"> YES<br>
<input type="radio" value="no" name="radio"> NO
<br>
<br>
 
<select size="1" name="drop_down">
<option>php</option>
<option>xml</option>
<option>asp</option>
<option>jsp</option>
</select><br>
<br>
Message:<br>
<textarea rows="9" name="message" cols="30"></textarea><br>
<br>
<input type="submit" value="Submit" name="submit">
</form>

<?php
}
?>

Thumbs up

Re: [TUTORIAL] How to make a simple contact form

I wish it were possible to see screenshots of what these samples look like, or maybe my problem is just that I still need to learn a lot of php basics.  It's probably me.

Thumbs up

Re: [TUTORIAL] How to make a simple contact form

Well it just looks like a form no special design its just the fields

-John

Thumbs up