Jump to content


Photo

Need Help with Form using $_Post


  • Please log in to reply
3 replies to this topic

#1 csimms

csimms
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 September 2006 - 07:24 PM

I am in the process of creating a form in Dreamweaver, but a friend of mine had told me I should use PHP to handle the processing of the form.
I have never used PHP and have been reading up on the basics and need some help with handling the form.

In the form I have the following

<FORM name=Comment action="process.php" method="post">

For the prcocess.php I have

this so far

<form name=comment method=post action=contact_thanks.php>
<p class=bodymd>All fields of this form are required to be filed in...</p>
<p class=bodymd>Fill in the ones you missed, they are listed below.</p>
<p class=bodymd>Your First Name<br><input type=text name=firstname></p>
<p class=bodymd>Your Last Name<br><input type=text name=lastname></p>
<p class=bodymd>Your Email Address<br><input type=text name=Emailaddress></p>
<p class=bodymd>Enter Date<br><input type=text name=Date></p>
<p class=bodymd>Select Class Taken<br><select=option name=classtaken></p>
<p class=bodymd>Comment or Questions<br><textarea name=Comment rows=20 cols=100></textarea></p>
<input type=submit name=Submit value=Submit><input type=reset name=Reset value=Clear Form></form>

I really need some help.. I have tried serveral different ways, what I need to happen is to have the form information the end user fills out sent to my email address in plain text or in the form format if possible..
I am trying to create a commment form for my site.. I would also like to put in place a way to stop any bots from sending spam..
Thank you for your help..


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 27 September 2006 - 07:33 PM

The easiest way to put the contents of a form into an email message is:
<?php
if (isset($_POST['submit'])) {
   $body = "The following information was sent via the form:\n";
   $body .= print_r(array_map(stripslashes,$_POST),true));
   mail($to,$subject,$body,$headers);
?>

It's not formatted, but it is completely readable.

Ken

#3 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 27 September 2006 - 07:48 PM

Well, if you are just looking to email the form values then you can do it ALL in HTML with ' mailto: '

but in php ...

<?php

if ($_POST) {

   foreach ($_POST as $key => $value) {

$data .=  "Element ($key): = $value

";

   }

}

$headers .= "From: \"senderaddress@senderdomain.com\"\n";

mail("yourtargetaddress@yourdomain.com", "Your subject", $data, $headers);

?>

<html>
<head>
<title></title>
</head>
<body>

<form name=comment method=post action=contact_thanks.php>
<p class=bodymd>All fields of this form are required to be filed in...</p>
<p class=bodymd>Fill in the ones you missed, they are listed below.</p>
<p class=bodymd>Your First Name
<input type=text name=firstname></p>
<p class=bodymd>Your Last Name
<input type=text name=lastname></p>
<p class=bodymd>Your Email Address
<input type=text name=Emailaddress></p>
<p class=bodymd>Enter Date
<input type=text name=Date></p>
<p class=bodymd>Select Class Taken
<select=option name=classtaken></p>
<p class=bodymd>Comment or Questions
<textarea name=Comment rows=20 cols=100></textarea></p>
<input type=submit name=Submit value=Submit><input type=reset name=Reset value=Clear Form></form>

</body>
</html>
Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com

#4 csimms

csimms
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 30 September 2006 - 05:50 PM

thank you for your help.. now how would i redirect the page to a thank you page?

thanks for all of your help...





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users