How DO I Make a Contact Form?! I Give Up!
I need to create a very simple contact form for my site. Let's just say it's a single field where you put your name, and then you click "submit" and it emails it to me.
I have tried a simple HTML mail form, but all it does is open Outlook Express and present me with a large pop-up box saying that my account is set up (I don't use Outlook). Anyway, I don't want this to happen at all whether the person uses Outlook or not. This code, I will add, was from a "email form maker" where all it does is present you with the raw code.
I then went on to using a PHP form. This too was also taken from an "email form maker", where it just gives you the code. This worked, up to the point that you clicked the "Submit" button, where is transferred me the contact.php, which displayed only the raw code used on that page!
Please help me! I give up! Could you please give the EXACT code for the page(s), so all I have to do is save it- everything I try to do just goes wrong!
As far as I know, to make an email form in PHP, there should be two pages- contact.htm and contact.php, but I may be incorrect.
Thank you for your help! I need it!
MrRSMan.
Use this one, its a sure one if ur server supports php
The web form
First of all, you need to construct your web form. This should start with the following...
<form method="POST" action="thanks.php">
The 'method' parameter indicates that all variables (data) collected are to be hidden and not placed in the URL. The most important part is the 'action' parameter as this indicates where the processing of the form should be done. The form may also be given a name but as this is optional, we've left it out in this case to keep everything simple.
Our example form will collect a name and an email address. The following lines will do this.
Name: <input type="TEXT" name="name">
Email: <input type="TEXT" name="email">
Then we need a submit button and a tag to indicate the end of the form.
<input type="SUBMIT" name="Submit" value="ok">
</form>
The thanks page
Once someone has clicked on the ok button to submit the details on our form, we should let them know that their form has been submitted. For this we need a thanks page. This should be a normal html page which you will have constructed. You should then rename your thanks page to 'thanks.php'. The php extension enables the web server to run the php code on that page before it is sent to the browser.
Under the <BODY> tag on your thanks page, please enter the following code...
<script language="php">
$email = $HTTP_POST_VARS[email];
$mailto = "email@address";
$mailsubj = "Form submission";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
Make sure that you replace 'email@address' in the code with your own email address.
It is better you use your own webmail instead of yahoo as it may not deliver to yahoo but your own webmail is a sure delivery