Forum Moderators: coopster
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
Now my hosting company wont change anything for me, and register_golbals is set to off - Which I want it to be because of security issues I hear.
Can I use sessions?
Thanks :)
Wes
<?php
include("includes/application.php");
if (isset($_POST['submit'])) {
// check username and password
$username = $_POST['username'];
$password = $_POST['password'];
if (!isset($username) ¦¦!isset($password)) {
print "Please enter all the information <br>";
print "<a href='login.php'>Click Here</a> to return to the login form.";
die;
}
// convert the password to md5 hash
$password = md5($password);
// check the database for the username and password
$user_check = mysql_query("SELECT * FROM ******* WHERE username = '$username' AND password = '$password'");
$user = mysql_num_rows($user_check);
if ($user > 0) {
$user_query = mysql_query("SELECT * FROM ******* WHERE username = '$username' AND password = '$password'");
$userinfo = mysql_num_rows($user_query);
session_register('username');
$_SESSION['username'] = $userinfo['username'];
session_register('firstname');
$_SESSION['firstname'] = $userinfo['firstname'];
session_register('lastname');
$_SESSION['lastname'] = $userinfo['lastname'];
session_register('email');
$_SESSION['email'] = $userinfo['email'];
print "You are now logged in ".$_SESSION['firstname'].".<br>";
print "<a href='index.php'>Click Here</a> to go to the admin section.";
} else {
print "Your login information was incorrect. Please enter your correct username and password.";
print "<a href='login.php'>Click Here</a> to return to the login form.";
}
} else {
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table width="450" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="125"><b>Username:</b></td>
<td width="325"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td width="125"><b>Password:</b></td>
<td width="325"><input name="password" type="password" id="password"></td>
</tr>
</table>
<input type="submit" name="submit" value="Submit">
</form>
<?php }?>