Bringing info from one page to another using _POST?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jkelly
Forum Newbie
Posts: 6
Joined: Tue May 31, 2005 10:12 am

Bringing info from one page to another using _POST?

Post 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
Revan
Forum Commoner
Posts: 83
Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:

Post by Revan »

Try:

Code: Select all

print_r($_POST);
print_r($_GET);
on the second page.
jkelly
Forum Newbie
Posts: 6
Joined: Tue May 31, 2005 10:12 am

Post 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?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

show us the code for your form
jkelly
Forum Newbie
Posts: 6
Joined: Tue May 31, 2005 10:12 am

Post 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!!
Post Reply