Skip to content

Commit

Permalink
Merge pull request #12 from kartiksaxena532/patch-2
Browse files Browse the repository at this point in the history
Create a form handler using PHP
  • Loading branch information
srijoy-paul authored Oct 13, 2022
2 parents 5a1480a + fc2e8c4 commit e813c05
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions FORM.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("[email protected]", $subject, $message, $from);
echo "Email sent!";
}
}
?>

0 comments on commit e813c05

Please sign in to comment.