rohan.weston Posted August 12, 2010 Share Posted August 12, 2010 Hi guys. I'm very new to PHP, and I'm trying to create a simple mail script. Mail a friend A user will click an image on the site which will open a pop up box. They input their name and the email of the friend that they want to send the current URL to. The email will send the current URL via email and display a confirmation message once it has sent successfully. The friend will receive an email with a link to the URL. The problem The email part works fine, it's the URL in the message that is the issue. When the user clicks the 'Email a friend' it opens a popup box - which is where the URL is being grabbed from and emailed. Is there a way to grab the URL from the page before the popup? Here is my (rather amateur) code. Also, feel free to let me know if I can make improvements to it if anything seems a bit strange! The popup link: <a onclick="window.open(this.href,'win2','width=400,height=350,menubar=yes,resizable=yes'); return false;" title="E-mail" href="mailform/form.html">Send to a friend</a> The popup form: <html> <body> <form method="post" action="code.php"> Friends Email: <input name="email" type="text" /><br /> Your Name: <input name="name" type="text" /><br /> <input type="submit" /> </form> </body> </html> The PHP code: <?php // Declaring Variables $email = $_REQUEST['email'] ; $name = $_REQUEST['name']; $geturl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $message = "Hello. $name has suggested a page for you to view on our website. Please click the following link: $geturl"; // Email Settings mail( $email, "Send page to a friend", $message, "From: Timaru District Council" ); header( "Location: http://www.c4clever.com/sandbox/mailform/sent.html" ); // Confirmation page (Change this to appropriate URL) ?> Feel free to test it out if you want to (http://www.c4clever.com/sandbox) Looking forward to replies, thanks in advance! Link to comment https://forums.phpfreaks.com/topic/210594-grabbing-a-url-via-popup/ Share on other sites More sharing options...
petroz Posted August 13, 2010 Share Posted August 13, 2010 If you know the url, you could embed it on the link the users have to click, then grab that value on the popup through $_GET['url']; Like so <a href="example.com/popup?url=example.com" target="_blank">Share with Friend</a> and on your popup page, just grab the contents of the $_GET['url']; Let me know that helps. Link to comment https://forums.phpfreaks.com/topic/210594-grabbing-a-url-via-popup/#findComment-1098690 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.