简体   繁体   中英

php contact form email information

i made a contactform and it almost works fine.

<?php
$contact_name = $_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_tel = $_POST['contact_tel'];
$contact_call = $_POST['contact_call'];
$contact_message = $_POST['contact_message'];
$formcontent=" Von: $contact_name \n Tel.: $contact_tel \n Rückruf: $contact_call \n Nachricht: <br> $contact_message";
$recipient = "jonathanrobrecht@googlemail.com";
$subject = "Kontaktformular";
$from = '$contact_email';
$mailheader = "Von: $contact_email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>

That is the php an when i sned an email i got in the email client the information of the subject but not who send the email(well the adress of my webserver is shown) but i want that the email which is filled in is the email.

I tried this:

$subject = "Kontaktformular";
$from = '$contact_email';

$subject does work, but from does not, how do i fixe this?

$from = '$contact_email';

Should be

$from = "$contact_email";

If you single quote it, PHP interprets it literally as '$contact_email'; if you double-quote it, it adds in the value of the variable instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM