lynxus Posted July 27, 2009 Share Posted July 27, 2009 Hi guys, I need to get php to visit a url ( to send a url some data ) ie: How can i do this. $password = "moo"; $username = "blaa"; send_to_url:http://blaaa.com/info.php?username=$password&password=$password I dont need to recieve a reply from the URL. Just need to send that data to it and that will be it. Any ideas how to do this? Thanks G Quote Link to comment Share on other sites More sharing options...
Q Posted July 27, 2009 Share Posted July 27, 2009 You should look into cURL. Edit: typos.. Quote Link to comment Share on other sites More sharing options...
ukweb Posted July 27, 2009 Share Posted July 27, 2009 First I urge you not to use GET when sending username and passwords, its a bad, bad idea!!! HTML for the sending page: <?php // Set the username and password. // The username and password boxes will be populated with this data $username = 'username_here'; $password = 'password_here'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>My Send Page</title> </head> <body> <form id="my_form" name="my_form" method="post" action="http://www.my_receiving_url/recieve.php"> <p>Username: <input name="username" type="text" id="username" value="<?php echo $username; ?>" /> <br /> Password: <input name="password" type="password" id="password" value="<?php echo $password; ?>" /> </p> <p> <input type="submit" name="send" id="send" value="Send" /> </p> </form> </body> </html> Don't forget to save as a PHP page! AND here's the page that receives the posted data: <?php // Set the username and password variables to the received info. $username = $_POST['username']; $password = $_POST['password']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>My Receive Page</title> </head> <body> <p> The Username sent was: <?php echo $username; ?><br /> The Password sent was: <?php echo $password; ?> </p> </body> </html> Yet again save as a PHP and change the paths that the form posts to. Quote Link to comment Share on other sites More sharing options...
lynxus Posted July 27, 2009 Author Share Posted July 27, 2009 Thanks guys, Unfortunately it out of my control how to do this as its an external website im sending the data to Normally i would use posts with plenty of error checking with sessions. Im not needing to do any forms etc. I just have a php script that needs to send some data to an external url. No need for a form etc. Just want inside my current php script to say: load this url, Dont return anything. Just load this url once. Quote Link to comment Share on other sites More sharing options...
lynxus Posted July 27, 2009 Author Share Posted July 27, 2009 Ah ha, Decided to use: $contents = file_get_contents('url'); Seems to work perfectly. 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.