Jump to content

Archived

This topic is now archived and is closed to further replies.

csimms

Need Help with Form using $_Post

Recommended Posts

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..

Share this post


Link to post
Share on other sites
The easiest way to put the contents of a form into an email message is:
[code]<?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);
?>[/code]

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

Ken

Share this post


Link to post
Share on other sites
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>

Share this post


Link to post
Share on other sites
thank you for your help.. now how would i redirect the page to a thank you page?

thanks for all of your help...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.