How To Make A Contact Form For Your Website
1 post
Page 1 of 1
hello guys hehaho;
i am now going to tell you how to create a contact form using php and html and i want to say that some of you may know how to create in other way some of you may not know how to create this so thats why i want to write .
i am using the same contact form on my website by the way i dont think it is advanced but its ok cooll;
first you need to create the php file so open your favorite text editor and add these php codes inside
this declares the $form variable and assign it the value of 'from: ' and the email
this EOD helps us to use formatted HTML In PHP
replace admin@example.com with your email address
replace shim with your name
this echo a server response
now save your html page and to test it you need to upload the files to your host ;)
thanks for reading and i hope this is helpful and again sorry for my bad english if anything bad or else 'do nothing :lol:
i am now going to tell you how to create a contact form using php and html and i want to say that some of you may know how to create in other way some of you may not know how to create this so thats why i want to write .
i am using the same contact form on my website by the way i dont think it is advanced but its ok cooll;
first you need to create the php file so open your favorite text editor and add these php codes inside
Code: Select all
now this is <?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$msg = $_POST['message'];
$from = 'From: ' . $email;
$message = <<<EOD
Hey Shim, Looks Like You Have a Contact <br />
<hr />
<br />
Name: $name
Email: $email
Subject of Inquiry: $subject
<br />
Message: <br />
$msg
<br />
<hr />
EOD;
mail('admin@example.com', $subject, $message, $from) or die("There was an error!");
echo 'Thanks for Contacting Us, We Will Get Back to Your Shortly!';
?>
Code: Select all
the name field and this is $name = $_POST['name'];
Code: Select all
the email field and this is $email = $_POST['email'];
Code: Select all
the subject field and this is the message field :ugeek: $subject = $_POST['subject'];
Code: Select all
$msg = $_POST['message'];
this declares the $form variable and assign it the value of 'from: ' and the email
Code: Select all
$from = 'From: ' . $email;
this EOD helps us to use formatted HTML In PHP
Code: Select all
this constructors the function mail()
$message = <<<EOD
Hey Shim, Looks Like You Have a Contact <br />
<hr />
<br />
Name: $name
Email: $email
Subject of Inquiry: $subject
<br />
Message: <br />
$msg
<br />
<hr />
EOD;
Code: Select all
mail('Your Email Here', $subject, $message, $from) or die("There was an error!");
replace admin@example.com with your email address
replace shim with your name
this echo a server response
Code: Select all
now save the file as send.php and now if you want to put the form in your contact form of your website open the html file in your notepad and find a place to have the contact form visible and add this codesecho 'Thanks for Contacting Us, We Will Get Back to Your Shortly!';
Code: Select all
the form action ="send.php" and the method "post" means the forms uses send.php for action and post :geek:
<form action="send.php" method="post">
<input id="sender" type="text" placeholder="Name" name="name" /><br /><br />
<input id="email" type="text" placeholder="Email" name="email" /><br /><br />
<input id="subject" type="text" placeholder="Subject" name="subject" /><br /><br />
<textarea id="contact-content" placeholder="Your enquiries" name="message"></textarea><br /><br />
<input id="consubmit" type="submit" name="consubmit" value="Send" /><br /><br />
</form>
now save your html page and to test it you need to upload the files to your host ;)
thanks for reading and i hope this is helpful and again sorry for my bad english if anything bad or else 'do nothing :lol:
Find my programs on Softpedia
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023