Page 1 of 1

Bringing info from one page to another using _POST?

Posted: Tue May 31, 2005 10:31 am
by jkelly
Hello,

I'm a complete newbie at PHP and am having an awful lot of trouble trying to pass username and password information from one page to the other..

The problem is, on one page I have textfields where the user enters their username and password and then clicks on submit. This brings them to another page that should display their information.

The probalem is, I cant seem to be able to bring the information they entered in the first page across to the second page... :?

I am trying to use _POST to do this but to no avail...

Any help would be very appreciated!!!

Cheers,
John

Posted: Tue May 31, 2005 10:44 am
by Revan
Try:

Code: Select all

print_r($_POST);
print_r($_GET);
on the second page.

Posted: Tue May 31, 2005 10:55 am
by jkelly
Hey,

Cheers for the reply. All I get when I do that is

Code: Select all

Array()
...which I figure means the POST array isnt being filled in the first page..

The code on the first page is

Code: Select all

$loginUsername = $_POSTї'username'];
which is referring to the username textfield... any idea on what I'm doing wrong?

Posted: Tue May 31, 2005 10:57 am
by JayBird
show us the code for your form

Posted: Tue May 31, 2005 11:16 am
by jkelly
Here's the code that I think is relevent on the first page

Code: Select all

<?php require_once('Connections/final.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER&#1111;'PHP_SELF'];
if (isset($accesscheck)) {
  $GLOBALS&#1111;'PrevUrl'] = $accesscheck;
  session_register('PrevUrl');
}

if (isset($_POST&#1111;'username'])) 
{
  $loginUsername=$_POST&#1111;'username'];
  $password=$_POST&#1111;'password'];
  $fldUserAuthorization = &quote;&quote;;
  $redirectLoginSuccess = &quote;checkout.php&quote;;
  $redirectLoginFailed = &quote;ERRregForm.php&quote;;
  $redirecttoReferrer = false;
  mysql_select_db($database_final, $final);
   
 $LoginRS__query=sprintf(&quote;SELECT username, Password FROM customer WHERE username='&quote; . $loginUsername . &quote;' AND Password='&quote; . $password . &quote;'&quote;);
 
  $LoginRS = mysql_query($LoginRS__query, $final) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = &quote;&quote;;
    
    //declare two session variables and assign them
    $GLOBALS&#1111;'Username'] = $loginUsername;
    $GLOBALS&#1111;'UserGroup'] = $loginStrGroup;	      

    //register the session variables
    session_register(&quote;Username&quote;);
    session_register(&quote;UserGroup&quote;);

    if (isset($_SESSION&#1111;'PrevUrl']) && false) {
      $redirectLoginSuccess = $_SESSION&#1111;'PrevUrl'];	
    }
    header(&quote;Location: &quote; . $redirectLoginSuccess );
  }
  else {
    header(&quote;Location: &quote;. $redirectLoginFailed );
  }
}
That is the top section of my php file and then the related textfields are created below with this code

Code: Select all

<form ACTION=&quote;<?php echo $loginFormAction; ?>&quote; name=&quote;frmCart&quote; method=&quote;POST&quote;>

...etc

<input name=&quote;username&quote; type=&quote;text&quote; id=&quote;username&quote;>
                </strong></font></p>
				<p align=&quote;center&quote;><font size=&quote;+1&quote;><strong>Password:  
				      
    <input name=&quote;password&quote; type=&quote;password&quote; id=&quote;password&quote;>
                </strong></font></p>
				<p align=&quote;center&quote;><strong>
				  <input type=&quote;submit&quote; name=&quote;Submit&quote; value=&quote;Submit&quote;>
				</strong></p>
</form>
Thanks for all the help too!!