View Full Version : php and forms
mlowery
March 7th, 2002, 21:11
hey, I am a newbie to php. I want to know how to take the contents of a form and send them to me. I know there is a mail() function. Where would I put the email address of where I want to info sent? and how would I print the info onto a page to send? In other words, I want to know how to make a form handler that will simply send me an email with the contents of the form in it. I know that it probably is a VERY simple script, like I said.. I am a newbie and want some experience.
Thanks
rapmaster
March 7th, 2002, 21:34
basically like this:
<form action="send_email.php" method="POST">
Message:<input type="text" size="22" name="message">
<input type="submit" value="send mail">
<?
$to = "you@yoursite.com";
$from_header = "From: $from";
if($contents != "")
{
//send mail - $subject & $contents come from surfer input
mail($to, $message, $contents, $from_header);
// redirect back to url visitor came from
header("Location: $HTTP_REFERER");
}
else
{
print("<HTML><BODY>Error, no comments were submitted!");
print("</BODY></HTML>");
}
?>
jiminsd
March 7th, 2002, 21:58
Here is a simple one that works pretty good for me:
http://www.lumbroso.com/scripts/
megapuzik
March 8th, 2002, 01:01
Do a search on mail in these forums, I once explained "Cheatpark" how to make mail form....(something like "step-by-step" tutorial :) )
mlowery
March 9th, 2002, 13:18
Thanks,
rapmaster....
In the form code where it says "Message:" then the rest of that code, what is the Message mean? Just for my information.... I will serch the forums now :)
Thanks
cheatpark
March 9th, 2002, 13:47
Originally posted by megapuzik
Do a search on mail in these forums, I once explained "Cheatpark" how to make mail form....(something like "step-by-step" tutorial :) )
Yeah it was a very good tutorial. I also customized it a bit so that it would redirect people and stuff.
rapmaster
March 9th, 2002, 13:56
Originally posted by mlowery
Thanks,
rapmaster....
In the form code where it says "Message:" then the rest of that code, what is the Message mean? Just for my information.... I will serch the forums now :)
Thanks
that would be the message you want to send. you could add more fields very easily as well just by adding more input boxes and including them in the mail() function. If u need an example I'd be glad to show you.
mlowery
March 9th, 2002, 14:35
It worked :) thanks.
http://mlowery.nirmani.net/tests/join.html
One more thing... How do I make it auto redirect to a page so that after they click submit it will send them to the .php page and the page will say ... "You will be redirected in two seconds" then it re-directs them.
thanks
cheatpark
March 9th, 2002, 14:39
Might as well be open source:
error_reporting(0);
/* turn off all error reporting */
if(!$email || !$websiteurl || !$bannerlocation)
{
print "Sorry, you didn't fill everything in. We're going to have to redirect you back to the form. This will take 2 seconds.";
echo '<meta http-equiv="refresh" content="2;URL=javascript:window.history.back()">';
}
else
{
$mail_msg="E-mail: $email, Website url: $websiteurl, Banner location: $bannerlocation";
mail("webmaster@cheatpark.net","Data posted from http://www.cheatpark.net/forms/feedback.php", $mail_msg);
print "Thank you very much. Your submittion was successfull and now you will be taken to our thank you page.";
echo '<meta http-equiv="refresh" content="2;URL=http://www.cheatpark.net/advertising/thankyou.php">';
}
?>
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.