Jump to content

[SOLVED] PHP to visit a url.


lynxus

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.