/    Sign up×
Community /Pin to ProfileBookmark

Hi all,

I am trying to perform the following code to isert the data in my database and receive an e-mail :

[code=php]
include (“intro.php”);
$first_name=$_POST[‘first_name’];
$last_name=$_POST[‘last_name’];
$email=$_POST[’email’];

$sql=”insert into reservation(first_name,last_name,email,)
values(‘$first_name’,’$last_name’,’$email’)”;
if(mysql_errno() == 0){
//add the user.
header(‘location:register.php’);
} else {
echo”<div align=’center’><strong><font color=’#003333′ size=’4′>Already existing user !! Please try another user name !!</font></strong>”;
};
?>
<?
$message =”<html>’$first_name'<br>,’$last_name'<br>,’$email’,</html>”;
$headers = ‘From: info@’ . $_SERVER[‘?’] . “rn” .
‘X-Mailer: PHP/’ . phpversion();

$ok=mysql_query($sql,$conexao);
IF($ok){
mail(‘[email protected]’, ‘Request’,$headers,$message);}
[/code]

The problem is that when I receive the e-mail, the sender is [email][email protected][/email]. How can I set it to be the ‘$email’ ? And also how to include html format on

[code=php]$message =”<html>’$first_name'<br>,’$last_name'<br>,’$email’,</html>”;[/code]

Thanks for any help

sandro27

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@jabezApr 01.2005 — $message ="<html>'$first_name'<br>,'$last_name'<br>,'$email',</html>";

You don't seem to be echoing the php variables into your script.

Perhaps you need to build the html message something like this:

$message ="<html>";

$message .= $first_name . "<br>";

$message .= $last_name . "<br>";

$message .= $email . "</html>";

Also you seem to have the header and message variables

in the email() function the wrong way round.

IF($ok){

mail('[email protected]', 'Request', $headers, $message);

}

Do you mean:

IF($ok){

mail('[email protected]', 'Request', $message, $headers);

}

What is 'Request' - that is where the mail subject line should go.

You could try something like this:

This should work as a plain text email. Try to get the mail working in plain text,

then alter it to send html email. You might need to remove the html tags first.

/* $email is the recipients email address - the person the email gets sent to

*
$subject is the subject line in the mail reader program

* - when a person receives the email

*
$body is the actual body of the email message

* $sender is the email address of the person sending the email

*
/

$body = $message;

// sender email address
$sender = "From: [email][email protected][/email]";

$mail_sent = mail($email, $subject, $body, $sender);

if (TRUE == $mail_sent)
{
echo "Mail sent to user: $email OK<BR>";
}
else
{
do some error recover/message here
}


HTH - Keith


--------------------------------------------------------------------------
Quote from the php manual:

// To send HTML mail, the Content-type header must be set

$headers = 'MIME-Version: 1.0' . "rn";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";

// Additional headers

$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "rn";

$headers .= 'From: Birthday Reminder <[email protected]>' . "rn";

$headers .= 'Cc: [email][email protected][/email]' . "rn";

$headers .= 'Bcc: [email][email protected][/email]' . "rn";

// Mail it

mail($to, $subject, $message, $headers);
Copy linkTweet thisAlerts:
@sandro27authorApr 02.2005 — Hi Keith,

Thanks a lot for the advice. It worked as I need it.

Best wishes

Sandro27 ?
×

Success!

Help @sandro27 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...