|
|
|
|
![]() ![]() |
May 30 2006, 12:26 AM
Post
#1
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 12 Joined: 29-May 06 Member No.: 24,489 |
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?
|
|
|
|
May 30 2006, 01:24 AM
Post
#2
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 3,994 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
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. |
|
|
|
May 30 2006, 03:05 AM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 205 Joined: 14-March 06 From: Vermont or Boston (USA) Member No.: 20,077 |
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 |
|
|
|
May 30 2006, 02:38 PM
Post
#4
|
|
|
Newbie ![]() Group: Members Posts: 3 Joined: 30-May 06 Member No.: 24,522 |
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']; This post has been edited by bapplay: May 30 2006, 02:39 PM |
|
|
|
May 30 2006, 04:21 PM
Post
#5
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 49 Joined: 22-April 06 Member No.: 22,255 |
QUOTE <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? |
|
|
|
May 31 2006, 04:02 AM
Post
#6
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 874 Joined: 30-July 04 Member No.: 246 |
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...
This post has been edited by Spectre: May 31 2006, 04:02 AM |
|
|
|
Jun 1 2006, 12:37 AM
Post
#7
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 12 Joined: 29-May 06 Member No.: 24,489 |
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 |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 6th September 2008 - 07:48 PM |