Jump to content

lgin script..cross browser issues....


almightyegg

Recommended Posts

it works fine in IE, but not in FireFox  :-[
[b]Welcome page:[/b]
[code=php:0]
<?
session_start(); // Session Start
include 'db.php'; // Connect to DB
session_register('email');
session_register('password');
$email = $_POST['email']; 
$password = $_POST['password'];
if((!$email) || (!$password)){ 
    echo "Please enter ALL of the information! <br />"; 
    include 'index.php'; 
    exit(); 


if((!$email) || (!$password)){ 
    echo "Please enter ALL of the information! <br />";
    echo "<a href=\"index.php\" />Click here to return to the main page</a>";
    exit(); 
}   

$sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password' AND activated='1'"); 
$login_check = mysql_num_rows($sql); 

if($login_check == 0){
$sql1 = mysql_query("SELECT * FROM users WHERE email='$email'");
$sql2 = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password'");
$sql3 = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password' AND activated='1'");
$c1 = mysql_num_rows($sql1); 
$c2 = mysql_num_rows($sql2); 
$c3 = mysql_num_rows($sql3);

echo "The following errors were found from your login.<br>";
    if($c1==0){
    echo "The email you've entered was not valid. Please go back and <a href=\"welcome.php\" />try again</a>.";
    }elseif($c2==0){
        echo "The password you've entered was incorrect. Please go back and <a href=\"welcome.php\" />try again</a>. If you would like your password sent to you via email please <a href=\"lostpw.php\" />click here</a>";
    }elseif($c3==0){
        echo "You did not yet validate your account! If you would like your validation code sent to you via email please <a href=\"resend.php\" />click here</a>.";
    }
}else{

//page goes here

}
[/code]

[b]All other pages:[/b]
[code=php:0]
<?
session_start(); // Session Start
include 'db.php'; // Connect to DB
$email = $_SESSION['email'];
$password = $_SESSION['password'];
if((!$email) || (!$password)){
echo "Please enter ALL of the information! <br />";
include 'index.php';
exit();
}

if((!$email) || (!$password)){
echo "Please enter ALL of the information! <br />";
echo '<a href=index.html>Click here to return to the main page</a>';
exit();
}

$sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);

if($login_check == 0){
$sql1 = mysql_query("SELECT * FROM users WHERE email='$email'");
$sql2 = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password'");
$sql3 = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password' AND activated='1'");
$c1 = mysql_num_rows($sql1);
$c2 = mysql_num_rows($sql2);
$c3 = mysql_num_rows($sql3);

echo"The following errors were found from your login.<br>";
if($c1==0){
echo"The email you've entered was not valid. Please go back and <a href=index.php>try again</a>.";
}elseif($c2==0){
echo"The password you've entered was incorrect. Please go back and <a href=index.php>try again</a>. If you would like your password sent to you via email please <a href=lostpw.php>click here</a>";
}elseif($c3==0){
echo"You did not yet validate your account! If you would like your validation code sent to you via email please <a href=resend.php>click here</a>.";
}
}else{

//page goes here

}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/27784-lgin-scriptcross-browser-issues/
Share on other sites

Oh, and here is my form...

[code]
<center>
<fieldset><legend>Login</legend>
<table border=0 cellpadding=10><tr><td valign=center>
<form method=POST action=welcome.php name=form1>
Email:<br> <input type=text name=email><bR><br>
Password:<br> <input type=password name=password><br><br>
<input type=submit value=Login!>
</form>
</td></tr></table>
</fieldset>
</center>
[/code]
for - one just reading over your code - you give the user WAY too much info about the username password combo. Just say "Somehting is off with eiter your un or pw" if i were a hacker and seen that i had the correct username but not the right password, i could create a bot that would brute force its way in.


Just so we can remove one possible problem, please use (something like) this as your log-in.  Halfway decent html never hurt anyone :)

[code]<center>
<fieldset><legend>Login</legend>
<table border="0" cellpadding="10"><tr><td valign="center">
<form method="post" action="welcome.php" name="form1">
Email:<br><input type="text" name="email"><br><br>
Password:<br><input type="password" name="password"><br><br>
<input type="submit" value="Login!">
</form>
</td></tr></table>
</fieldset>
</center>[/code]

Archived

This topic is now archived and is closed to further replies.

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