|
Answer» I have Dreamweaver, and I would like to know how to make it so a form send information to a specific email address. I have no idea whatsoever of how to do this.I had the same question a while ago. This will help you. Read the instructions carefully. http://www.webmaster-talk.com/php-forum/35929-feedback-form.html ... For other website questions, you might try http://www.webmaster-talk.com
FlameOK, Looks simple and easy (not what I thought it would be) I will mess around with that code and see if I can get it. ThanksSure thing. Keep us posted on how you do. As usual, come back and see us if you have any more questions as well
FlameWhen I click "Send the Form" it goes the the Pagetwo.php, but gives me the code.
It shows this:
<?php
$body_of_message= $_POST['message']. "\n"; $body_of_message .= "Sent by " . $_POST['name']; $subject= "Message from the feedback form";
if(mail("[email protected]",$subject,$body_of _message)) { echo "Your message was sent."; } else { echo "There was a problem."; };
?>
It does not send anything. What do I do to fix the problem?It's easy enough to design the form, but then you need a program to process the data sent by the form. In this case, the data is being sent to a PHP script. If you don't have a PHP-enabled webserver, this will not do you any good.Check into that. Who is your host? We need to make sure they support PHP... Good point Rob
FlameHey,
Well I'm in Information Technology and I have done a lot of dreamweaver and forms in my Web course. To send form information to an e-mail address, you have to include the following after your first or second heading in your code:
Some email servers will let you open the browser automatically when the button is pressed. Some you might not be able to. Also, depending on your e-mail configuration, you may receive warning dialog boxes or be given a chance to edit the e-mail message.
Hope it helps! Sometimes seeing code is better at helping you learn it. Here is a simple form that is commented so you can see what to change and what each section does. This example does require you to have a PHP enabled server. Hope this helps!
Code: [Select]<?php echo " <center>";
//BEGIN PROCESSING EMAIL if ($_POST['name']){
//CHECK YO SEE IF REQUIED FIELDS ARE EMPTY if(empty($_POST['name']) || empty($_POST['email'])){
//IF A REQUIRED FIELD IS EMPTY SHOW THIS TO USER echo " <div class='plaintext'><br />Please fill out the form completly</div><br />"; }
//IF ALL FIELDS ARE FILLED OUT SEND THE MESSAGE INFORMATION else{ $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/")); $message="Name: ".$name." Email: ".$email." Yahoo: ".$yahoo." MSN: ".$msn." Comments: ".$Comments." "; $message = stripslashes($message);
//EDIT REQUIRED:::::::::::CHANGE [email protected] TO YOUR EMAIL ADDRESS //EDIT REQUIRED:::::::::::CHANGE FROM: YOUR WEBSITE TO FROM: <WHAT YOU WANT> mail("[email protected]","Contact Us Form Submitted",$message,"FROM: YOUR WEBSITE"); //END PROCESSING EMAIL
//BEGIN SHOWING WHAT THE USER SUBMITTED echo " <div class='txtSession'>Thank you. You input this information.</div>";
echo " <table width=75%>";
echo " <tr>"; echo " <td><div class='txtSession'>Name:</div></td>"; echo " <td><div class='txtSession'>$name</div></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Email:</div></td>"; echo " <td><div class='txtSession'>$email</div></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Yahoo:</div></td>"; echo " <td><div class='txtSession'>$yahoo</div></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>MSN:</div></td>"; echo " <td><div class='txtSession'>$msn</div></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Comments:</div></td>"; echo " <td><div class='txtSession'>$Comments</div></td>";
echo " </tr>";
echo " </table>"; //END SHOWING WHAT THE USER SUBMITTED } }
//BEGIN THE CONTACT FORM echo " <br/><br/>";
echo " <form method='post' action='contactus.php' target='_self'>";
echo " <table width='75%' border='0'>";
echo " <tr>";
echo " <td><div class='txtSession'>Name *</div></td>"; echo " <td><input type='text' size='30' name='name' class='textbox'></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Email *</div></td>"; echo " <td><input type='text' size='30' name='email' class='textbox'></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Yahoo</div></td>"; echo " <td><input type='text' size='30' name='yahoo' class='textbox'></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>MSN</div></td>"; echo " <td><input type='text' size='30' name='msn' class='textbox'></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Comments</div></td>"; echo " <td> </td>";
echo " </tr><tr>";
echo " <td colspan='2'><textarea cols='50' name='Comments' rows='5' class='textbox'>Give us your feedback, good or bad!</textarea></td>";
echo " </tr>";
echo " </table>"; echo " <div align='center'><input type='submit' value='Submit Form'> <input type='reset' value='Clear Form'></div>";
echo " </form>"; //END THE CONTACT FORM echo " </center>"; ?>(later responce, better server, more fun!) OK, now I get this: Parse error: syntax error, unexpected T_STRING in /home/jessez/public_html/password_content/process_request.php on line 39 Please post the section of code that includes that line. I'll need to see the line immediately above it for debugging purposes. Please clearly indicate which is the correct line, 'cause I ain't gonna count it for you. Ok, I didn't know that I needed the same code for this. Since all of this, the file has been modified. The new error code is this: Parse error: syntax error, unexpected T_STRING in /home/jessez/public_html/password_content/process_request.php on line 8
Here's the actual code, with lines and numbers.
Code: [Select]1 |<p> 2 | <?php 3 | 4 |$body_of_message= $_POST['message']. "\n"; 5 |$body_of_message .= "Sent by " . $_POST['name']; 6 |$subject= "Message from the feedback form"; 7 | 8 |if(mail("[email protected]",$subject,$body_of _message)) { 9 |echo "Your message was sent."; 10|} else { 11|echo "There was a problem."; 12|}; 13| 14|?> 15|</p> 16|
And just for everyone's entertainment, a screenshot of this is includedGot it. It was very hard to spot!
On the line
if(mail("[email protected]",$subject,$body_of _message)) { you have a space in the middle of the variable name, "$body_of _message", before the second underscore. Delete it. "Your message was sent." unless there's a hidden side to that message, everything is working. Thanks!
But that wasn't the only problem, the email address was wrong. But I fixed that to.
All seems to be well, now to see if it sends understandably.
Edit: oh great. All I see in the message is this:
From [email protected] Fri Jun 23 15:00:22 2006 Return-path: <[email protected]> Envelope-to: [email protected] Delivery-date: Fri, 23 Jun 2006 15:00:22 -0500 Received: from nobody by orbit.serverz.org with local (Exim 4.52) id 1FtrpF-0004w3-Rn for [email protected]; Fri, 23 Jun 2006 15:00:21 -0500 To: [email protected] Subject: Message from the feedback form Message-Id: <[email protected]> From: Nobody <[email protected]> Date: Fri, 23 Jun 2006 15:00:21 -0500 Status: R Simple headers
Sent by Are you sure that POST variables are reaching this form? You can test by echoing them within your script (commenting out the mail section until you have verified that part is working.I bet you that I dont have any "POST" variables. I bet there all set to "GET"
Lets find out...
connecting to remote server... sorting list of remote folders... It was set to "GET" I changed it to "POST" I will see what happens now.
-----POST MERGE-----
Changed "GET" to "POST" and it didnt work. I did give the server time to update. All I get is: Date: 6/24/2006 14:01:14 -0500 From: Nobody <[email protected]> To: [email protected] Subject: Message from the feedback form All headers Sent by and nothing more. What could be the problem? (BTW: IM not the best at this "form" stuff. It could just be a simple error or something missing. But I dont know what.)4| $body_of_message= $_POST['message']. "\n"; 5| $body_of_message .= "Sent by" . $_POST['name'];
I see the words "Sent By" in each message I get. Should the above lines have something different?At the top of your script please add the following:
<?php print_r($_POST); ?>Please then show the results - this will print the contents of the $_POST array.This appears when you submit the form
Array ( [name_nickname] => name [date_created] => date [My_notes_to_add_on_site] => NOTES [my_email] => email [show_my_email] => checkbox [my_commet] => commets [my_website] => website [I_agree_to_let_you_change_my_notes_name_and_any_info_you_provide_to_me] => checkbox [Send] => Send )
Your message was sent.
Email recived shows as: Sent by
I have made a special directory on my site to show what this is supposed to do, it contains most of the previous code, but was somewhat altered.
Please visit www.jessez.mbhosting.com/chtest/ for more information
|