Email Form help

biferi

Daemon Poster
Messages
690
I am trying to put an Email Form on my web site the kind that you would fillout and then Hit submit and it will Automaticly e mail it to me.

But all I come across is forms that you need to have some kind of .PhP File put in your CGi Bin and then code your page.

And I tryed it and the Form never comes up right on my page and it never e mails it to me.

Then I see all over the net that this kind of Email Form never realy works.

So does anyone know of a way I can maybe do it by hand with HTML Code and not have to use all this ather Files and CGi Bins????
Thanks
 
Truth be told you will need to have some type of action script for a form to really function well. You don't need a very complicated script for the form to work.

If you give me some information on what exactly you are looking for I can try and put together something that will work for you.

Cheers!
 
I just want a Form that has a Box to type their Name in.
And a box to type their Masssage in.

Then they will hit submit and it will e mail it to me by it'self.

And I don't know how to put up a picture??
 
Hi,

Ok, give me a day or so and I will put something together for you. It might not be exactly what you want but I will give you a template for you. I will make the php script work for you reguardless of how you change the form.

Cheers!
 
What software for your website are you using? Sounds a little like VB's Contact Us which appears at the bottom of the main index page.
That can get hit by spammers if it's not protected by a human challenge like re-captcha or something like it.

Also you might check over at www.dynamicdrive.com and see if they have something already put together that would work.
 
Hi,

Here is what I have for the form so far. I think that it should work, I am just working on the php now.

Code:
<form action="email.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p>Message:<br />
<textarea name="message" rows="25" cols="50"></textarea><br/>
<input type="submit" />
</form>

Cheers!
 
wmorri is spot on for the form. When you set the form's method to post, the inputs are posted back to the server. The code in your email.php file would look like this:
PHP:
$from = "sender@mysite.com";
$to = "recipientEmail@domain.com";
$subject = "Thanks for your submission!";
$body = "Thank you " . $_POST['name'] . " for contacting us!";
$adminTo = "you@yourdomain.com";
$adminBody = "A user has requested information:<br />\n";
$adminBody .= "Name: " . $_POST['name'] . "<br />\n";
$adminBody .= "Message: " . $_POST['message'] . " <br />\n";
$headers  = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n"; 
mail($to,$from,$body,$headers); // sends the e-mail
mail($adminTo,$from,$adminBody,$headers); // send an administrative e-mail.
I didn't run that, but if memory serves, thats all you need aside from configuring the php.ini file to point to a default mail server to handle the request.

It sends two e-mails. One to the user letting them know you received their submission, and one to you informing you that you received one.

the headers (content-type) allows you to put html in the e-mail instead of plain text. the built-in "mail" function I used returns 1 on success and false on failure. You could put this in an if statement to check and see if the operation completed.

Hope this helps.

Also notice the $_POST[] variable. This is a global variable that exists on every post back to the server. It is an array whose contents are the form values that were posted back. The 'text' part that goes in the square braces corresponds to the name="" attribute of your input element in your form.
So $_POST['name'] in your case, pulls whatever value they entered into the <input type="text"> field where it's name="" attribute equals "name".
In wmorri's code:
Code:
<input type="text" name="name" />
 
Daeva,

Thanks for doing the php part for me. I am not to good with php yet. I usually have some friends that help me with that.

Cheers!
 
Can we go step by step because these thingsa never work for me.
So I just want to make sure I am doing it right??

Everything in the PhP File you have listed I type say in Notepad and save it as . PhP right??

What do I have to Ad Or Change??

Just tell me this first.

Thanks.
 
Back
Top Bottom