Jump to content

reload to new page


legohead6

Recommended Posts

first off, you do not want to send information like the user's name and password through the url.

but, assuming that you have no html output before the validation, you can use the header function (example):

[code]
<?php
   session_start();
   if ($_POST['user'] and $_POST['pass']) {
       $results = mysql_query('select * from table where username='".$_POST['user']."' and password = '".$_POST['pass']."'");
      if (mysql_fetch_rows($results) == 1) {
         $_SESSION['info'] = mysql_fetch_array($results);
         header ('location: blah.php'); exit;
      } else {
         echo 'login failed';
   }
[/code]

i added in session_start(); and then creating a session variable that holds the user's info as an alternative method of passing the information via url. on your target page (blah.php) you would start it off with session_start(); as well. then you can access the information through the info session variable.
Link to comment
https://forums.phpfreaks.com/topic/9900-reload-to-new-page/#findComment-36806
Share on other sites

ya i coded the pass, also say i wanted to retrieve the pass...what would i use?(never used a session before)

thanks
Matt

[!--quoteo(post=374863:date=May 17 2006, 11:39 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 17 2006, 11:39 PM) [snapback]374863[/snapback][/div][div class=\'quotemain\'][!--quotec--]
first off, you do not want to send information like the user's name and password through the url.

but, assuming that you have no html output before the validation, you can use the header function (example):

[code]
<?php
   session_start();
   if ($_POST['user'] and $_POST['pass']) {
       $results = mysql_query('select * from members where username='".$_POST['user']."' and password = '".$_POST['pass']."'");
      if (mysql_fetch_rows($results) == 1) {
         $_SESSION['info'] = mysql_fetch_array($results);
         header ('location: blah.php'); exit;
      } else {
         echo 'login failed';
   }
[/code]

i added in session_start(); and then creating a session variable that holds the user's info as an alternative method of passing the information via url. on your target page (blah.php) you would start it off with session_start(); as well. then you can access the information through the info session variable.
[/quote]
Link to comment
https://forums.phpfreaks.com/topic/9900-reload-to-new-page/#findComment-36899
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.