Jump to content


Photo

reload to new page


  • Please log in to reply
4 replies to this topic

#1 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 18 May 2006 - 03:33 AM

hi i have a login thingy(not prfessional but works) and it validates it on the same page then i want it if sucessfull(already setup) to automaticly go to the new page witch is "main.php?user=$user&pass=$pass" but i cant get it to automaticly go(without clicking a link)
"Syntax error" .. WHERE THE **** IS IT?!

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 18 May 2006 - 04:39 AM

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):

<?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';
   }

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 18 May 2006 - 02:33 PM

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) View Post[/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):

<?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';
   }

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]

"Syntax error" .. WHERE THE **** IS IT?!

#4 eddedwards

eddedwards
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 18 May 2006 - 03:04 PM

just a side question for you.

this code:

if ($_POST['user'] and $_POST['pass']) {

is that shorthand for:

if (isset($_POST['user']) and isset($_POST['pass'])

ive always used isset to check my postvars.
can i get away with just doing it the way you wrote?

#5 mjozwiak

mjozwiak
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 19 May 2006 - 01:08 AM

You can if you are using it in an if statemnt but its safe to use it if you just checking for other vairbles




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users