Jump to content

Recommended Posts

Hi,

 

I have a login on www.ycreate.com which was working on another cpanel server. recently i changed host and now when i've uploaded the files no one can log in as the session seems to fail..

 

I beleive this to be server side but my host state it's not

 

can someone try it and give advice on what they need to activate for it to work

 

username: testaccount

password:test

 

website: www.ycreate.com

 

 

I can provide the code if required.

Link to comment
https://forums.phpfreaks.com/topic/182684-session-login/
Share on other sites

i see it as pointless the code is working but okay.

 

Login form.

 

<form name="login"  class="login" method="post" action="login.php">
   <label>Username</label> <input type="text" name="user" size="20" maxlength="20" style="width:148px; height:16px;" /><br/><br/>
   <label>Password</label> <input type="password" name="pass" size="20"  maxlength="20"  style="width:148px; height:16px;" /><br/>
   
  <input name="submit" type="submit" value="Login" class="submit" /> 
  </form>

 

login.php

 


<?php 

include("config.php"); 

session_start(); 

?>
<?php



if (!$user || !$pass) {



include("head2.php"); 



print "Please fill out all fields.";



exit;



}



include("header1.php"); 



$logres = mysql_num_rows(mysql_query("select * from players where user='$user' and pass='$pass'"));



$stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'"));



if ($logres <= 0) {
;



exit;



} else {



session_register("user");



session_register("pass");



}

  $unixtime = time();

  	  $b = date("g:i a d-m-Y",$unixtime);



$ip = " $_SERVER[REMOTE_ADDR] ";



mysql_query("update players set ip='$ip' where id=$stat[id]");

mysql_query("update players set lastonline='$b' where id=$stat[id]");

mysql_query("update players set logins=logins+1 where id=$stat[id]");



?>
blah blah page so on!!!

Link to comment
https://forums.phpfreaks.com/topic/182684-session-login/#findComment-964282
Share on other sites

and sorry header1 is

 


<?















if (!session_is_registered("user") || !session_is_registered("pass")) {







print "<center><font color=silver>Your session is over you will need to log back in....<a href=index.php>CLICK HERE</a>.";







exit;







}







$stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'"));







if (empty ($stat[id])) {







print "Invalid login.";







exit;







}

Link to comment
https://forums.phpfreaks.com/topic/182684-session-login/#findComment-964285
Share on other sites

Your code relies on both register_globals and session_register() (and probably session_is_registered() and session_unregister()). All of these were turned off by default in php4.2 in April of the year 2002, over 7 years ago. All of these have also been completely removed in php6, so now is the time to update the code to current php standards.

 

Link to comment
https://forums.phpfreaks.com/topic/182684-session-login/#findComment-964299
Share on other sites

Hi,

 

This line of code will always stop here and go no further.  Because when you call

include("header1.php"); 

it checks the below.  These global vars (user && pass) have not been set yet and "exit" will terminate the script.

 

<?if (!session_is_registered("user") || !session_is_registered("pass")) {	print "<center><font color=silver>Your session is over you will need to log back in....<a href=index.php>CLICK HERE</a>.";	exit;}

 

Also session_is_registered has been deprecated.  Use isset() on the $_SESSION global var.  e.g. !isset($_SESSION['user'])

Link to comment
https://forums.phpfreaks.com/topic/182684-session-login/#findComment-964301
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.