indiodoido Posted August 26, 2007 Share Posted August 26, 2007 hi... I have a form in my site, and i would like to send the data from that form in a HTML email. I can send the HTML email, but i can't see the users data that was inserted in the form :-( I've got this script: <?php //Name of the Person $namenew = $_GET['name']; //Email Id of the person $emailnew = $_GET['email']; //Feedback detail $feedbacknew = $_GET['feedback']; // multiple recipients $to = 'some@teste.com'; // note the comma // subject $subject = 'rLD-i.com Form Feedback'; // message $message = ' <html> <style type="text/css"> <!-- body { font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #999999; text-align: justify; } --> </style> <head> <title>rLD-i.com</title> </head> <body> <p>Got a new feedback from <?php echo $_GET['name']; ?>. Ele submeteu a seguinte informação:</p> <table> <tr> <td>Email: <?php echo "$emailnew;" ?></td> </tr> <tr> <td>Detailss: <?php echo $feedbacknew['feedback']; ?></td> </tr> </table> </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: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n"; $headers .= 'From: rLD-i.com <birthday@example.com>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?> How can i display the input data from the form inside de HTML code? Can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/66798-html-email-with-php/ Share on other sites More sharing options...
EagerWolf Posted August 26, 2007 Share Posted August 26, 2007 The problem is: When you are writing in $message: ... w feedback from <?php echo $_GET['name']; ?>. Ele submeteu a ... $message is already a part of PHP... So why do you put <?php inside? Example: $var1 = "Something"; $var2 = "Something else"; $together = $var1." and ".$var2; print $together; // Will output Something and Something else That's the proper way of combining variables in php... You can add to one variable the value of another as well: Example: $var1 = "Something"; $var2 = "Something else"; $var1 .= " and ".$var2; print $var2; // Output is the same as in example above... So the proper code is: <?php //Name of the Person $namenew = $_GET['name']; //Email Id of the person $emailnew = $_GET['email']; //Feedback detail $feedbacknew = $_GET['feedback']; // multiple recipients $to = 'some@teste.com'; // note the comma // subject $subject = 'rLD-i.com Form Feedback'; // message $message = ' <html> <style type="text/css"> <!-- body { font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #999999; text-align: justify; } --> </style> <head> <title>rLD-i.com</title> </head> <body> <p>Got a new feedback from '.$_GET['name'].'. Ele submeteu a seguinte informação:</p> <table> <tr> <td>Email: <?php echo "$emailnew;" ?></td> </tr> <tr> <td>Detailss: '.$feedbacknew['feedback'].'</td> </tr> </table> </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: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n"; $headers .= 'From: rLD-i.com <birthday@example.com>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?> I hope it helped! Quote Link to comment https://forums.phpfreaks.com/topic/66798-html-email-with-php/#findComment-334724 Share on other sites More sharing options...
matthewhaworth Posted August 26, 2007 Share Posted August 26, 2007 The problem is: When you are writing in $message: ... w feedback from <?php echo $_GET['name']; ?>. Ele submeteu a ... $message is already a part of PHP... So why do you put <?php inside? Example: $var1 = "Something"; $var2 = "Something else"; $together = $var1." and ".$var2; print $together; // Will output Something and Something else That's the proper way of combining variables in php... You can add to one variable the value of another as well: Example: $var1 = "Something"; $var2 = "Something else"; $var1 .= " and ".$var2; print $var2; // Output is the same as in example above... So the proper code is: <?php //Name of the Person $namenew = $_GET['name']; //Email Id of the person $emailnew = $_GET['email']; //Feedback detail $feedbacknew = $_GET['feedback']; // multiple recipients $to = 'some@teste.com'; // note the comma // subject $subject = 'rLD-i.com Form Feedback'; // message $message = ' <html> <style type="text/css"> <!-- body { font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #999999; text-align: justify; } --> </style> <head> <title>rLD-i.com</title> </head> <body> <p>Got a new feedback from ' . $_GET['name'] . '. Ele submeteu a seguinte informação:</p> <table> <tr> <td>Email: <?php echo "$emailnew;" ?></td> </tr> <tr> <td>Detailss: ' . $feedbacknew['feedback'] . '</td> </tr> </table> </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: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n"; $headers .= 'From: rLD-i.com <birthday@example.com>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?> I hope it helped! You missed one <?php //Name of the Person $namenew = $_GET['name']; //Email Id of the person $emailnew = $_GET['email']; //Feedback detail $feedbacknew = $_GET['feedback']; // multiple recipients $to = 'some@teste.com'; // note the comma // subject $subject = 'rLD-i.com Form Feedback'; // message $message = ' <html> <style type="text/css"> <!-- body { font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #999999; text-align: justify; } --> </style> <head> <title>rLD-i.com</title> </head> <body> <p>Got a new feedback from '.$namenew.'. Ele submeteu a seguinte informação:</p> <table> <tr> <td>Email: ' . $emailnew . '</td> </tr> <tr> <td>Detailss: '.$feedbacknew.'</td> </tr> </table> </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: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n"; $headers .= 'From: rLD-i.com <birthday@example.com>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?> Also, I changed the variables round, $_GET['feedback'] might have been an array, but i doubted it.. look at the beginning of the script, you've already renamed the variables so why put the old ones into the $message var? Quote Link to comment https://forums.phpfreaks.com/topic/66798-html-email-with-php/#findComment-334727 Share on other sites More sharing options...
EagerWolf Posted August 26, 2007 Share Posted August 26, 2007 Yup I guess so But that's what will solve the problem Hehe Quote Link to comment https://forums.phpfreaks.com/topic/66798-html-email-with-php/#findComment-334729 Share on other sites More sharing options...
indiodoido Posted August 26, 2007 Author Share Posted August 26, 2007 hey guys! thanks alot...it's working Quote Link to comment https://forums.phpfreaks.com/topic/66798-html-email-with-php/#findComment-334735 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.