the sr5 Posted April 23, 2008 Share Posted April 23, 2008 Ok once again found that my old scripts are no longer working... can anyone take a look at these and let me know what they think.... reason i have all my old scripts are because they were all backed up from my old host and i just reopened my site again with a new host... here are the 3 files that i normally use as my login script functions.inc.php <? function connect() { @mysql_connect("localhost", "username", "password"); } function login($username, $passwd) { // check username and password with db // if yes, return true // else return false // check if username is unique $result = mysql_query("select * from mysql_database.user where username='$username' and passwd = password('$passwd')") or die(mysql_error()); if (!mysql_num_rows($result)) { return 0; } else { return 1; } } function login2($username, $passwd) { // check username and password with db // if yes, return true // else return false // check if username is unique $result = mysql_query("select * from mysql_database.user where username='$username' and passwd = password('$passwd')") or die(mysql_error()); if (!mysql_num_rows($result)) { return 0; } else { return 1; } } function check_valid_user() { // see if somebody is logged in and notify them if not global $valid_user; if (session_is_registered("valid_user")) { echo "Logged in as $valid_user."; echo "<br>"; } else { // they are not logged in echo "Problem:"; echo "You are not logged in.<br>"; } } ?> do_login2.php: <? require 'functions.inc.php'; connect(); session_start(); if ($username && $passwd) { if (login($username, $passwd)) { session_register("valid_user"); $valid_user = $username; $login = Post; header("Location: index.php"); exit(); } else { if (login2($username, $passwd)) { session_register("valid_user"); $valid_user = $username; $login = Post; header("Location: index.php"); exit(); } else { $error = "Incorrect Login"; header("Location: index.php?error=$error"); exit(); } } } ?> login.php: <FORM METHOD="POST" ACTION="do_login2.php"> <font size="1" face="verdana" color="000000"><IMG SRC="images/arrow.gif"><IMG SRC="images/arrow.gif"> Login <table border=0 width="100%"> <tr> <td align=left><div class="txt4">UserID:</div><center><INPUT TYPE="text" NAME="username" SIZE=16 class=txt2></center> </td> </tr><tr> <td align=left><div class="txt4">Password:</div><center><INPUT TYPE="password" NAME="passwd" SIZE=16 class=txt2></center></td> </tr> </table> <center><INPUT TYPE="image" src="images/lbutton.gif"></center> </FORM> If anyone could help, that would be great... it just doesn't seem that anyone of my old scripts seem to work... do i need to head out here in the next week and purchase a new php for dummies?? All these scripts were written back in the day, they are about 3-4 years old im still extremely rusty but still understand for the most part what needs to be done, but as i can see i dont see the error in these three files! Link to comment https://forums.phpfreaks.com/topic/102456-login-script/ Share on other sites More sharing options...
awpti Posted April 23, 2008 Share Posted April 23, 2008 Turn on register_globals ini_set('register_globals', 'on'); at the top of an always-included script. If you're lucky, you have control over this. Or rewrite your app to be compliant with PHP5. Link to comment https://forums.phpfreaks.com/topic/102456-login-script/#findComment-524680 Share on other sites More sharing options...
the sr5 Posted April 23, 2008 Author Share Posted April 23, 2008 Where exactly does this need to go? ini_set('register_globals', 'on'); i put it at the top of my functions script and do_login2 and still no dice... what would be the fastest way for me to update this code to PHP5? Link to comment https://forums.phpfreaks.com/topic/102456-login-script/#findComment-524682 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.