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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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