PHP Contact Form

Joined
Nov 20, 2010
Messages
37
Reaction score
2
Here is code...One part is PHP, one is HTML...

PHP Code

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

   $to = "mail id"; 
   $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 {
   echo "Error, please try again!";
}
?>

HTML CODE:

Code:
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>

<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>

</body>

</html>
 
What about your code? Did you want to ask anything? If yes what? Or is it just pure code as a kind of explanation?
I don't get why you are just opening a thread stating : here is PHP code, and here is a HTML-site without telling any reason why you posted it
 
What about your code? Did you want to ask anything? If yes what? Or is it just pure code as a kind of explanation?
I don't get why you are just opening a thread stating : here is PHP code, and here is a HTML-site without telling any reason why you posted it

I think he's sharing code which is pretty pointless because it looks very generic and doesn't deal with any security.
 
I think he's sharing code which is pretty pointless because it looks very generic and doesn't deal with any security.
Didn't think about this. Well it is very basic code, but to some newbies it might be helpfull (escpecially for those who do never google anything :D )
 
Back
Top