Jump to content

Recommended Posts

Hi,

 

I have created a login that once worked on another server and i have changed the register globals on in the php.ini.. when I hit login the page does nothing..

 

the page is located at www.ycreate.com/sos to see what i mean the login code is below..

 

 

any idea's?

 

LOGIN FORM

<form method="post" action="index.php?cmd=login">

<font size="3"><B>PLAYERS LOG IN BELOW</B><br />
<br />
<BR>

</font><table border="0" style="font-family = Verdana; font-size = 12px">

<tr><td><font size="1">Username:</font></td><td><font size="1"><input type="text" size="15" name="inUser" style="<?php echo $boxStyle;  ?>"></font></td></tr>

<tr><td><font size="1">Password:</font></td><td><font size="1"><input type="password" size="15" name="inPass" style="<?php echo $boxStyle;  ?>"></font></td></tr>

<tr><td colspan="2" align="center"><font size="1"><input type="submit" value="Login"></font></td></tr>

</table></form>

 

LOGIN SCRIPT


(DB CONNECT)

<? if ($cmd == "login")

{

   setcookie('sosuser' , $inUser);

   setcookie('sospass' , $inPass);

   if ($_COOKIE['sossess'] == "")

   {

      $sql = "SELECT val FROM tickers WHERE id=1";

      $r = mysql_query($sql);

      $row = mysql_fetch_row($r);

      $next = $row[0];

      setcookie('sossess', $next, time()+60*60*24*365);

      $sql = "UPDATE tickers SET val=val+1 WHERE id=1";

      mysql_query($sql);

   }

   header('location: index.php?cmd=home');

}else if ($cmd == "logout")

{

   setcookie('sosuser' , ' ');

   setcookie('sospass' , ' ');

   header('location: index.php');

}





if ($cmd == '') { $cmd = 'default'; }



$userid = -1;

if (in_array($cmd, $iPages))

{



   $sql = "SELECT id,team FROM users WHERE username='{$_COOKIE['sosuser']}' AND password='{$_COOKIE['sospass']}'";

   $r = mysql_query($sql);

   if (mysql_num_rows($r) == 0)

   {

      $cmd = "badlogin"; 

   }else

   {

      $row = mysql_fetch_row($r);

      $userid = $row[0];

      $teamid = $row[1];



      $sql = "UPDATE users SET lastaction=".time()." WHERE id={$userid}";

      mysql_query($sql);

   }



}

include ("serv.php");



if (!in_array($cmd, $noHeader))

{

   echo 'LOGGED IN' {;
?>

Link to comment
https://forums.phpfreaks.com/topic/191237-login-does-nothing/
Share on other sites

Register_globals were turned off by default nearly 8 years ago because they were the stupidest thing a programming language ever did. They have been completely removed in php6.

 

Instead of wasting your time every time you switch servers, just spend a little time fixing your code to use the correct variable where the data is coming from, it will work on all server configurations -

 

$cmd = $_GET['cmd'];

 

You should also use full opening <?php tags to again keep from wasting your time every time you switch servers and the short open tag setting is not ON. Full opening tags will work on all server configurations.

Link to comment
https://forums.phpfreaks.com/topic/191237-login-does-nothing/#findComment-1008322
Share on other sites

Did you check if register_globals were actually ON? In programming, you cannot ASSUME * anything. You must always check to make sure what a value is. It is not enough to just change a setting because there are a dozen different things that could prevent that setting from taking affect.

 

* ASSUME = To make an ASS out of U and ME

Link to comment
https://forums.phpfreaks.com/topic/191237-login-does-nothing/#findComment-1008394
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.