hujtec 0 Report post Posted May 30, 2006 Hello I've been trying to connect two PHP scripts that have their separate logins. I want to create a PHP script that will use POST to send the username/password to another PHP script. I tried a lot of scripts but I can't seem to make it work. I have no idea how to find out what is wrong, has anybody any experience in this field? Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted May 30, 2006 What have you tried so far? To move from page to page on a site and maintain data about the user's log-in status (ie: id and password) and various other info, look at using cookies or sessions. Share this post Link to post Share on other sites
gaea 0 Report post Posted May 30, 2006 Ok, on the origonal page you need to use php to dynamicly write the username and password into a hidden form. It'll look something like this:<form action="nameOfSecondPage.php" method="post"><input type="hidden" name="username" value="<?php $username ?>"><input type="hidden" name="password" value="<?php $password ?>"><input type="submit" value="Goto next page"></form>Then on the second page you just get the variables that you sent, like so:<?php$username=$_POST['username'];$password=$_POST['password'];?>Hope that helped, feel free to ask if you have any other questions Share this post Link to post Share on other sites
bapplay 0 Report post Posted May 30, 2006 (edited) Hello I've been trying to connect two PHP scripts that have their separate logins. I want to create a PHP script that will use POST to send the username/password to another PHP script. I tried a lot of scripts but I can't seem to make it work. I have no idea how to find out what is wrong, has anybody any experience in this field? people often just forget to declare back there variables that are transfered from on page to the other. Make sure that all form varialbles are declared....eg $name=$_POST['formvariable']; Edited May 30, 2006 by bapplay (see edit history) Share this post Link to post Share on other sites
AlanDS 0 Report post Posted May 30, 2006 <form action="nameOfSecondPage.php" method="post"><input type="hidden" name="username" value="<?php $username ?>"><input type="hidden" name="password" value="<?php $password ?>"><input type="submit" value="Goto next page"></form>In the above script, the user has to click the button "Goto next page"but what if he follows any link? Share this post Link to post Share on other sites
Spectre 0 Report post Posted May 31, 2006 (edited) Assuming I understand your problem correctly, you can either specify the script in the 'action' value of the form (eg. '<form action="/target_script.php" method="post">), or include() the script from the page that you have the form submit data to. The $_POST variable is an 'autoglobal', meaning that any section of any script has access to it. So if, for example, you use include('other_script.php'); from within target_script.php, then other_script.php will have full access to the $_POST variable. If that makes sense... Edited May 31, 2006 by Spectre (see edit history) Share this post Link to post Share on other sites
hujtec 0 Report post Posted June 1, 2006 I think my question was not clear enough. You are talking about the usual POST usage.. user clicks a button and the form data is sent. I was thinking more like automatic posting from PHP (see example )I tried everything, but the above link now works for me.. I'm really happy about that. Thanks anyway Share this post Link to post Share on other sites