mystiklady Posted November 18, 2007 Share Posted November 18, 2007 Hello: Very new to PHP, downloaded a free script to use on my site, though I don't like how the "from" part of the email shows either my server (if I delete the line $headers . . ) or the words represented in this line ($headers . . .) I would like the "from" to represent who filled out the "recommend site". Please help! Here is code: <HTML> <HEAD> <CENTER> <body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#669966" alink="#996666"> <font face=" verdana, tahoma" font size="-2"> <?php if (!$HTTP_POST_VARS["from"] || !$HTTP_POST_VARS["say"]) { echo "Please fill in all fields."; echo '<a href="javascript:history.go(-1)">Go Back</a>'; exit; } ?> <?php include('config1.php'); $time = date ("h:i A"); $date = date ("l, F jS, Y"); $urlh = getenv(HTTP_HOST); $url = "http://$urlh"; $IP = $_SERVER['REMOTE_ADDR']; $to = $_POST['to']; $subject = $_POST['subject']; $say = $_POST['say']; $from = $_POST['zigi']; $msg = $_POST['msg']; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Admin' . "\r\n"; $bodys .= (" I visited re:fresh skin and body and loved what they offer! <br><hr> "); $bodys .= "<li>Hi $from,</b> <br>"; $bodys .= "$mailbody<br>"; $bodys .= "$msg <br><br>"; $bodys .= "This message was submitted from $zigi, $say<br>"; $subject .="Message from $zigi "; $body = $body . $bodys; mail($to, $subject, $body, $headers); ?> <?php include('config1.php'); $urlh = getenv(HTTP_HOST); $url = "http://$urlh"; $email; $date = date ("l, F jS, Y"); $time = date ("h:i A"); $subject = "Info"; $body = $_POST['body']; $bodys = "Message:\n$msg\nThis form was submitted on Your Web Site on\n $date at\n $time.\n From IP Address.$IP \n From E Address\n$say\nTo E Address\n $to. \nUrl.\n $url "; $IP = $_SERVER['REMOTE_ADDR']; $body = $body . $bodys; mail($email, $subject, $body, "From: $email"); ?> <html> <head> <style> <!-- body, P.msoNormal, LI.msoNormal { background-position: top; background-color: #ffffff; margin-left: 2em; margin-top: 0em; margin-bottom: 4em; font-family: "verdana"; font-size: 9pt; font-weight: bold; color: "#151B8D"; } --> </style> </head> </body> <?php include('config1.php'); ?> <center><strong><p><font face="verdana" size="2" color="#000000">Thank you! Your email has been sent to</font> <?php echo $from; ?>. <a href="javascript:window.close()">Close the Window</a></a>?</p> <br> <br> <p><font face="verdana" size="2" color="#000000">or send to another friend! </font><a href="index.php">Send Wish List</a></p> </body> <br><br><br><br><br><br> <center> </center> <br><br><br><br><br><br> <center> <font face=" verdana, tahoma" font size="-2"><b> <?php $urlv = "http://phpform.net"; ?> copyright <a target='_BLANK' href=<?php echo $siteurl; ?>><?php echo $powered; ?></a><br> </b> </font> </center> </html> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 18, 2007 Share Posted November 18, 2007 try this: <HTML> <HEAD> <CENTER> <body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#669966" alink="#996666"> <font face=" verdana, tahoma" font size="-2"> <?php if (!$HTTP_POST_VARS["from"] || !$HTTP_POST_VARS["say"]) { echo "Please fill in all fields."; echo '<a href="javascript:history.go(-1)">Go Back[/url]'; exit; } ?> <?php include('config1.php'); $time = date ("h:i A"); $date = date ("l, F jS, Y"); $urlh = getenv(HTTP_HOST); $url = "http://$urlh"; $IP = $_SERVER['REMOTE_ADDR']; $to = $_POST['to']; $subject = $_POST['subject']; $say = $_POST['say']; $from = $_POST['zigi']; $msg = $_POST['msg']; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: $from' . "\r\n"; $bodys .= (" I visited re:fresh skin and body and loved what they offer! "); $bodys .= "<li>Hi $from, "; $bodys .= "$mailbody "; $bodys .= "$msg "; $bodys .= "This message was submitted from $zigi, $say "; $subject .="Message from $zigi "; $body = $body . $bodys; mail($to, $subject, $body, $headers); ?> <?php include('config1.php'); $urlh = getenv(HTTP_HOST); $url = "http://$urlh"; $email; $date = date ("l, F jS, Y"); $time = date ("h:i A"); $subject = "Info"; $body = $_POST['body']; $bodys = "Message:\n$msg\nThis form was submitted on Your Web Site on\n $date at\n $time.\n From IP Address.$IP \n From E Address\n$say\nTo E Address\n $to. \nUrl.\n $url "; $IP = $_SERVER['REMOTE_ADDR']; $body = $body . $bodys; mail($email, $subject, $body, "From: $email"); ?> <html> <head> <style> <!-- body, P.msoNormal, LI.msoNormal { background-position: top; background-color: #ffffff; margin-left: 2em; margin-top: 0em; margin-bottom: 4em; font-family: "verdana"; font-size: 9pt; font-weight: bold; color: "#151B8D"; } --> </style> </head> </body> <?php include('config1.php'); ?> <center><strong><p><font face="verdana" size="2" color="#000000">Thank you! Your email has been sent to</font> <?php echo $from; ?>. <a href="javascript:window.close()">Close the Window[/url][/url]?</p> <p><font face="verdana" size="2" color="#000000">or send to another friend! </font><a href="index.php">Send Wish List[/url]</p> </body> </center> Quote Link to comment Share on other sites More sharing options...
mystiklady Posted November 18, 2007 Author Share Posted November 18, 2007 Hello: Thanks for replying. I tried your code and got this: $from@myserver.com in the From line. I want people to open the email they receive, which is why I want the "from" to reflect the person who has "recommended" the site and not to say it's from my server as they probably won't recognize it and therefore not open. This is driving me crazy and if anyone knows of a good PHP generator software, that would be a great help! Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 18, 2007 Share Posted November 18, 2007 hi there replace $HTTP_POST_VARS with $_POST <?php if ($_POST['from']=="" || $_POST['say']=="") { ?> when using quotes make sure to escape them with dots and single quotes so they parse right <?php $headers .= 'From: '.$from.'' "\r\n";?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 18, 2007 Share Posted November 18, 2007 modifying the final mail statement: <?php mail($to,$subject,$body,$headers); ?> Quote Link to comment Share on other sites More sharing options...
mystiklady Posted November 18, 2007 Author Share Posted November 18, 2007 Hello: I tried replacing: $headers .= 'From: System Admin' . "\r\n"; with what you said: $headers .= 'From: '.$from.'' "\r\n"; and got an error message. With the first statement . . . $headers .= 'From: System Admin' . "\r\n"; . . . I get an email with System Admin in the "From" line, which is not what I want. What did I do wrong with the code you suggested? Thanks! Dianna Quote Link to comment 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.