Jump to content

PHP Form problem


Natechs

Recommended Posts

Use the mail() function, of course! :) It's very easy. The $to and $subject parameters are just what they sound like. Format all your post data so it looks the way you want to read it - newline characters and such. Then put all that in the $message parameter. In the $additional_headers parameter, you'll want 'From: ' and then a return address on your server. Can be the same as your $to parameter. http://www.php.net/manual/en/function.mail.php

Link to comment
Share on other sites

I tried but got this: Here Any reason why?

<?php// multiple recipients$to  = 'natecdog@gmail.com' . ', '; // note the comma// subject$subject = 'Web page request';// message$message = 'You are REQUEST["name"]; Your email is $_REQUEST["email"];Your background color will be $_REQUEST["bgcolor"];.The font color is $_REQUEST["fcolor"];All the fonts are listed as $_REQUEST["fonts"];The title is $_REQUEST["title"];The image url(s) are echo $_REQUEST["images"];Any other info is $_REQUEST["otherinfo"];';// To send HTML mail, the Content-type header must be set$headers  = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";// Additional headers$headers .= 'To: Nate <natecdog@gmail.com>' . "\r\n";$headers .= 'From: Web Page request' . "\r\n";// Mail itmail($to, $subject, $message, $headers);?>

Link to comment
Share on other sites

Okay, so I got my form working because of my new server and it sends the email but it doesn't have any data!Try it yourselvesCode:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>Page title</title></head><body><?php// multiple recipients$to = 'natecdog@gmail.com' . ', '; // note the comma// subject$subject = 'Web page request';// message$message = '<html><head><title>Page request</title></head><body>I am <?php echo $_POST["name"]; ?>.<br> My email is <?php echo $_POST["email"]; ?>.<br>I want my background color to be <?php echo $_POST["bgcolor"]; ?>.<br>My font color is <?php echo $_POST$_REQUEST["fcolor"]; ?>.<br>All the fonts I want are <?php echo $_POST["fonts"]; ?>.<br>The title is <?php echo $_POST["title"]; ?>.<br>My image url(s) are <?php echo $_POST["images"]; ?>.<br>Any other info is <?php echo $_POST["otherinfo"]; ?>.<br></body></html>';// To send HTML mail, the Content-type header must be set$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";// Additional headers$headers .= 'To: Nate <natecdog@gmail.com>' . "\r\n";$headers .= 'From: Web Page request' . "\r\n";// Mail itmail($to, $subject, $message, $headers);?><p>Thank you for your request. Expect a reply within 1 (one) working day. <a href="index.php">Go back to Nathan's site</a></p></body></html>

Link to comment
Share on other sites

I am <?php echo $_POST["name"]; ?>.<br>My email is <?php echo $_POST["email"]; ?>.<br>I want my background color to be <?php echo $_POST["bgcolor"]; ?>.<br>My font color is <?php echo $_POST$_REQUEST["fcolor"]; ?>.<br>

All these PHP statements aren't going to work. This is a string, it's not outputted HTML.You'll have to do it this way:

I am ' . $_POST["name"] . '.<br>My email is ' . $_POST["email"]; . '.<br>I want my background color to be ' . $_POST["bgcolor"]; . '.<br>My font color is ' . $_POST["fcolor"]; . '.<br>All the fonts I want are ' . $_POST["fonts"]; . '.<br>The title is ' . $_POST["title"]; . '.<br>

And so on with all the variables in your code.

Link to comment
Share on other sites

I'll try that. But I have one more question. Is there a way I can send that data to a MySQL database?EDIT: It didn't work. ResultCODE:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>Page title</title></head><body><?php// multiple recipients$to = 'natecdog@gmail.com' . ', '; // note the comma// subject$subject = 'Web page request';// message$message = "<html><head><title>Page request</title></head><body>I am ' . $_POST["name"] . '<br>My email is ' . $_POST["email"]; . '<br>I want my background color to be ' . $_POST["bgcolor"]; . '<br>My font color is ' . $_POST["fcolor"]; . '<br>All the fonts I want are ' . $_POST["fonts"]; . '<br>The title is ' . $_POST["title"]; . '<br></body></html>";// To send HTML mail, the Content-type header must be set$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";// Additional headers$headers .= 'To: Nate <natecdog@gmail.com>' . "\r\n";$headers .= 'From: Web Page request' . "\r\n";// Mail itmail($to, $subject, $message, $headers);?><p>Thank you for your request. Expect a reply within 1 (one) working day. <a href="index.php">Go back to Nathan's site</a></p></body></html>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...