Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/66798-html-email-with-php/
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/66798-html-email-with-php/#findComment-334724
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/66798-html-email-with-php/#findComment-334727
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.