View Full Version : Creating form and need help with php
bmiles
01-02-2008, 12:51 PM
Hello All
I am really new to creating forms and scripts, and what I am trying to do is create a form that a user would fill out and when they hit submit button, it would be sent to my email address. I have the form all made up in dreamweaver but I am not sure how to make the script and where to put it on hostmonster. Again I am very new to this so any easy to read info would be great! Also maybe a way make it secure so I dont get spammed
Thanks!
canmann
01-02-2008, 03:50 PM
I am also new to the scripting thing. I went to this site:
http://www.emailmeform.com/?page=cphome
and used it in my own web site. It works great, though I think Mozilla users need to right click first to enter data
You can check out my form at http://jojos-place.com/html/sign-up.html
Tyler
01-04-2008, 02:39 PM
Formmail is pretty easy to setup. Just follow the directions. http://www.scriptarchive.com/formmail.html
justafriend
01-04-2008, 08:56 PM
Heres what I used on my website for php email:
1-You need two pages; one on which youll have your form (ie, name, message, etc) and the other page to put the php script on it, to actually send the message.
Basically you could have a form.php and a thankyou.php page.
Create your form page, and in it, put your html for the form. Heres one you can use :
--------------------------
<form method="post" action="thankyou.php">
<input type="text" name="visitor"><br />
<input type="text" name="visitormail"><br />
<textarea rows="10" cols="50" name="notes"></textarea><br />
<input type="submit" value="Send Mail" />
</form>
-----------------------------
The important attributes here are the form method="post" and action"thankyou.php"
The post function is normal html, itll send all the content of your form to the thankyou.php page, on which you will install the php script that will actually send it to your email.
You can, of course, alter the above form to suit your needs. Let me know if you need help with that..
Then, on the thankyou.php page, what I suggest is that you make a copy of all the code on your form.php page. (This way, when the user clicks on submit, and gets sent to thankyou.php, it will still have the same look) You can add a thank you message, and/or remove the form script so that users dont see it again.
Here is the script for the php, simply paste it anywhere on your thankyou.php page:
----------------------------------
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
// In testing, if you get an Bad referer error
// comment out or remove the next three lines
if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 ||
!strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
die("Bad referer");
$msg="Values submitted by the user:\n";
foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $key\n";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $v\n";
}
} else {
$val = stripslashes($val);
$msg.="$key: $val\n";
}
}
$recipient="YOUREMAILADDRESS@SERVER.COM";
$subject="Form submission";
error_reporting(0);
if (mail($recipient, $subject, $msg)){
echo "THIS WILL DISPLAY THE MESSAGE THAT YOU WISH TO YOUR USER ONCE HE HAS SUBMITTED HIS COMMENT FROM THE FORM. CHANGE THIS TO WHATEVER KIND OF THANKYOU MESSAGE YOU WANT.
\n";
echo nl2br($input);
} else
echo "An error occurred and the message could not be sent.";
} else
echo "Bad request method";
?>
--------------------------------
Let me know if you need any further help. You can also check my website for an example of how the form works. Feel free to send me test messages on the Contact page.
gorgewarehouse
06-10-2008, 01:45 AM
@justafriend: I just wanted to say thank you for your contribution to this forum. I found your code to be simple for a newbie like me. I hope you don't object to me copying it on my site. (I assumed that's what it's there for.)
BTW, you have a good voice and great music. Good luck with your career!
goramsey132
06-06-2009, 02:26 PM
My form is built. All I need to know is how to create a submit button. The one I have just opens my email. I don't want that. I want the form sent to an email address. Any help would sure be appreciated. I have tried and can't get there from here.
Thanks
lmarik
06-16-2009, 05:46 PM
canmann - did you not notice that the form generated by emailmeform.com runs it past their own php form processor? It looks to me like they could be (if they want to) scraping all of the information that your users are entering.
Oh - justafriend - thanks loads for your examples - my newsletter subscription form is now sending the subscribers' info to the appropriate e-mail address. Now I just have to figure out how to handle confirmation and storing to database :-)
websitebuilder101
06-18-2009, 02:07 AM
This form looks good, but does it prevent 2 things (I am new at this so maybe it does):
1) Does it stop spam bots from sending you messages? I think many people add image verifications on their website to prevent this.
2) Doesn't this still leave your email address available to be picked up, even if it is in the php form? How do you still get it to send to "MYEMAIL@MYDOMAIN.COM" without having any bots be able to know that is your email.
Thanks for your help and sorry if that is an advance question.
shadmego
06-18-2009, 02:27 AM
There are lots of ways you can hide your email address from harvesters.
Perhaps two of the most common are:
1. Obfuscate your email address (http://www.google.com/search?q=obfuscate+email&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a). Basically what this does is use javascript to "encode/encrypt" your email address so harvesters can't see it, but it renders like a normal "mailto:yadda@yadda.yadda" to everyone else.
2. Use a database to store your email along with a number for identification. What you do is put your email address in a database with an id # attached to it. In your form, you use the ID number to identify the recipient and when your visitor submits the form, your have a php script look inside the database for the email address that matches the number sent by the form.
=========== Found the link ============
I found it. The script I am referring to makes use of some hidden fields to keep the spammers at bay. In fact, in finding it, I also realized I used a third technique to "hide" my email address. I didn't put it in the form at all. I simply moved it to the processing script. It is similar to the database option I mentioned above, but without the extra step of a database query.
Check out the script (and view the source) at www.directnb.com/tests/contact/
Of course, neither of these stop spammers from using your form, but as you correctly identified, typically a captcha will keep most automated spammers away. You can also try to use spam lists to check against known email and IP addresses. If a match occurs, the form is not submitted.
One thing I read a few months ago that I thought was VERY interesting is to not use captcha, but hidden form fields, like a text area. Upon form submission, if the hidden text area has data inside, then there is a very high likelihood a spammer is trying to send stuff. I have a sample somewhere, but I can't find the link right now. I will post when I remember where I put the form.
thanks to "justafriend" i now have a working email form!!! i have been looking around for days and there are never any instructions where to ACTUALLY put the scripts. thanks for making it simple. thanks
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.