Jul 25, 2008

Php Post Command

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Php Post Command

hujtec
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?

Reply

jlhaslip
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.

Reply

gaea
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

Reply

bapplay
QUOTE(hujtec @ May 29 2006, 06:26 PM) *

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'];

Reply

AlanDS
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?

Reply

Spectre
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...

Reply

hujtec
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. biggrin.gif

Thanks anyway

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. multiple post commands in form - 1.53 hr back. (2)
  2. php back command - 17.59 hr back. (1)
  3. get and post command html - 68.52 hr back. (1)
  4. "command line" php $_post - 73.50 hr back. (1)
  5. how to post hidden value to next page in php - 118.64 hr back. (1)
  6. variables not transfered by post commant php - 139.36 hr back. (1)
  7. php post command - 3.90 hr back. (10)
Similar Topics

Keywords : php, post, command

  1. Looking For Command Line Based Sql Modification
    Program Needed For SQL? (1)
  2. Question: Anybody Know How To Make Print Command?
    (23)
    I want my site (with PHP) to enable PRINT command. The usual print, with printer as output I mean.
    So, how can I do it? I've seen my college site use ASP and they can give me a PRINT xommand box,
    when I click it the printer will print the page.....
  3. Restarting Apache With Exec Command
    apache restart (0)
    Hey im trying to restart apache throug a script and so far none of the php or perl scripts have
    worked and its just driving me mental restarting apache in the command window in windows is a
    simple as just typing apache -k restart and when i do that i works , but when i create a script to
    execute that command it fails, and when i try to create a script to execute a batch file that does
    exactly that it still fails, so im stranded will someone help me out please, coz this is really
    getting annoying.....
  4. I Will Provide You With A Php Code That..
    ..enable you to use the 'echo' command. (0)
    **YOU DO NOT NEED ANY HTML TAGS FOR THIS SCRIPT**** Enter all values between the ' ' quotes
    //Define The Variables $cfg = array('sitename' => '', //Your Sites Name
    'footer' => '', //OPTIONAL, if you want your footer stored so that the
    echo command can display it. Ex: Copright ©2005 - Michael Fratello (the © is will turn
    into the copyright 'c') 'board_dir' => '', //Link to your
    message boards. (If you have any) ); ?> I recommend saving this file ....

    1. Looking for php, post, command

Searching Video's for php, post, command
advertisement



Php Post Command



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE