I need help with this code. This is the 2nd page of the code. The first page has the form and everything is fine with it. Basically I want the response message to be within the body of the html page (see bolded code for location ) but this code is just showing the message and not the rest of my html page like my logo (see italicized code for location). Can anyone please help? <?php $page_to_send = $_GET['page'] . ".php"; $domain = "http://www.domainname.com/"; $complete_url = $domain . $page_to_send; if (isset($_POST['submit'])) { $sendername = $_POST['sendername']; $senderemail = $_POST['senderemail']; $recipname = $_POST['recipname']; $recipemail = $_POST['recipemail']; $custmessage = $_POST['message']; $urltosend = $_POST['urlsent']; $staticmsg = "Hi $recipname! \n Your Colleague $sendername has recommended that you read this article from domain name with the following message: \n $custmessage."; $staticmsg = "$urltosend"; $staticmsg = "SITE PROMOTION TEXT AREA"; $staticmsg = "SITE PROMOTION TEXT AREA"; $staticmsg = "SITE PROMOTION TEXT AREA"; $ipaddress = $_SERVER['REMOTE_ADDR']; $subject = "A colleague has recommended this article!"; $headers = "From: My Domain \r\n"; $headers .= "Reply-To: $senderemail"; if (mail($recipemail,$subject,$staticmsg,$headers)){ echo "<p>Success. Your message was sent. Go back to the <a href=\"$urltosend\">page you were previously browsing</a>?</p>"; } else { echo "<p>Your message could not be sent at this time. Go back to the <a href=\"$urltosend\">page you were previously browsing</a>?</p>"; } } else { ?> <html> <head> <title>PAGE NAME</title> <meta name="robots" content="noindex,nofollow"> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" language="JavaScript" src="scripts/rollover.js"></script> <table width="600" border="0"> <tr> <td colspan="3"><div align="left"><a href="index.htm"><img src="images/logo.gif" alt="" width="313" height="80" border="0"></a><br> <br> </div></td> </tr> <tr> <td width="60"> </td> <td width="480" class="txt">Thanks for recommeding our article. An e-mail has been sent to <b>$recipemail</b>.<br><br></td> <td width="60"> </td> </tr> <tr> <td width="60"> </td> <td width="480" align="center"><a href=\"$urltosend\">Back to the Article</a></td> <td width="60"> </td> </tr> </table> </body> </html> <?php } ?>
I have no clue what that means as I do not know anything about php. I just found this code on like hotscripts or one of those sites and I am trying to adjust it to what I want.
Find: } else { ?> Replace with: } else { echo ' Find: <?php } Replace with: '; } ?> Try that and see if it works.
no it didn't work. It still showed the "Success. Your message was sent. Go back to the page you were previously browsing?" message and not anything within the html code. I don't even want it to show that part at all. I want it so when it is a success it shows: Thanks for recommeding our article. An e-mail has been sent to <b>$recipemail</b>. and when it fails it shows: Your message could not be sent at this time. Go back to the <a href=\"$urltosend\">page you were previously browsing</a>
I think I have it working except one little piece. When it is succesful it shows the message I want except the email is not showing. I am guessin that part of the code is messed up a little. It is the bolded piece below. <?php $page_to_send = $_GET['page'] . ".php"; $domain = "http://www.domainname.com/"; $complete_url = $domain . $page_to_send; if (isset($_POST['submit'])) { $sendername = $_POST['sendername']; $senderemail = $_POST['senderemail']; $recipname = $_POST['recipname']; $recipemail = $_POST['recipemail']; $custmessage = $_POST['message']; $urltosend = $_POST['urlsent']; $staticmsg = "Hi $recipname! \n Your Colleague $sendername has recommended that you read this article from domain name with the following message: \n $custmessage."; $staticmsg = "$urltosend"; $staticmsg = "SITE PROMOTION TEXT AREA"; $staticmsg = "SITE PROMOTION TEXT AREA"; $staticmsg = "SITE PROMOTION TEXT AREA"; $ipaddress = $_SERVER['REMOTE_ADDR']; $subject = "A colleague has recommended this article!"; $headers = "From: My Domain \r\n"; $headers .= "Reply-To: $senderemail"; } ?> <html> <head> <title>PAGE NAME</title> <meta name="robots" content="noindex,nofollow"> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" language="JavaScript" src="scripts/rollover.js"></script> <table width="600" border="0"> <tr> <td colspan="3"><div align="left"><a href="index.htm"><img src="images/logo.gif" alt="" width="313" height="80" border="0"></a><br> <br> </div></td> </tr> <tr> <td width="60"> </td> <td width="480" class="txt"> <?php if (mail($recipemail,$subject,$staticmsg,$headers)) { echo 'Thanks for recommeding our article. An e-mail has been sent to <b><?="$recipemail"; ?></b>.'; } else { echo 'Your message could not be sent at this time. Go back to the <a href=\"$urltosend\">page you were previously browsing</a>'; } ?> <br><br></td> <td width="60"> </td> </tr> <tr> <td width="60"> </td> <td width="480" align="center"><a href=\"$urltosend\">Back to the Article</a></td> <td width="60"> </td> </tr> </table> </body> </html>
Yup it's messed up, you start php again without closing it (the <? ?> tags) - change it to: echo 'Thanks for recommeding our article. An e-mail has been sent to <b>$recipemail</b>.';
...except I think you'll need to put it in double quotes, like: echo "Thanks for recommeding our article. An e-mail has been sent to <b>$recipemail</b>."; If you use single quotes, you have to concatinate, like: echo 'Thanks for recommeding our article. An e-mail has been sent to <b>'.$recipemail.'</b>.'; Salsa _______
Ok. So far so good, but I got three more questions. #1 - I want to put the link to the send a friend form on my article pages and I want it to be a 600x500 pop-up. <a href="tellafriend.php?page=<?=$page;?> class="a_link">Email a Colleague</a> Is this the correct code to use? #2 - It is not sending the email to the recipient. Is there something missing or is it the server I am using that isn't sending the email? #3 - In the code in the original post at the bottom there is the link that says Back to the Article with this code: <td width="480" align="center"><a href=\"$urltosend\">Back to the Article</a></td> When i clicked this link, it did not work properly. Can you tell me what is wrong?