Jump to content

Need Help with Form using $_Post


csimms

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..
Link to comment
https://forums.phpfreaks.com/topic/22283-need-help-with-form-using-_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
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: \"[email protected]\"\n";

mail("[email protected]", "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>

Archived

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

×
×
  • Create New...

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.