Jump to content

[SOLVED] php not working in Firefox, IE is ok


erikbeam

Recommended Posts

I've got a login page that goes through a php page to check the database, then it either routes to the content or to .../wrong_id.php.

 

Here's the form I'm sending to login:

 

<form name="login" method="post" action="login.php">
   Username:<input name="user" type="text"  size="16"/><br>
   Password:<input name="pass" type="password"  size="16"/><br>
   <input type="submit" name="login" value="Login"/>
   <input type="reset" name="reset" value="Reset"/>
</form>

 

and the database checking .../login.php

 

<?php
$con=mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dbname", $con); 



$query = sprintf("SELECT username, password, email, gallery FROM customer WHERE username='%s' AND password='%s'",
    mysql_real_escape_string($user),
    mysql_real_escape_string($pass));
$result = mysql_query($query);

while ($row = mysql_fetch_assoc($result)) {
    $dbuser = $row['username'];
    $dbpass = $row['password'];
    $dbemail = $row['email'];
    $dbgallery = $row['gallery'];
}

echo $dbuser;
echo $dbpass;

if($dbpass)
{
  	$_SESSION['sessionuser'] = $dbuser;
$_SESSION['sessiongallery'] = $dbgallery;
$_SESSION['sessionpassword'] = $dbpass;
echo "<meta http-equiv=\"refresh\" content=\"0;URL=gallery/index.php\">";
}
else
session_destroy();
echo "<meta http-equiv=\"refresh\" content=\"0;URL=wrong_id.php\">";
?>

 

I've got the echo's in there just to see if the variables are being passed.  They are.

 

On .../wrong_id.php I've got:

 

<?php
echo   	$_SESSION['sessionuser'];
echo	$_SESSION['sessiongallery'];
echo	$_SESSION['sessionpassword'];
?>

 

 

just to see if the variables are in fact being read.  They are.  This works fine in IE, but not in Firefox.  If the right user/password is entered, IE will route to the content.  Firefox routes to .../wrong_id.php no matter what.  The thing I don't get is since the variables are being passed, it means that the php is working, and since Firefox shouldn't even see the login.php site, why would it react any differently?  The only thing I can think is that the data Firefox sends to the server must be different in some way between IE and Firefox.

 

Any suggestions?  Thanks.

Link to comment
Share on other sites

if($dbpass)
{
  	$_SESSION['sessionuser'] = $dbuser;
$_SESSION['sessiongallery'] = $dbgallery;
$_SESSION['sessionpassword'] = $dbpass;
echo "<meta http-equiv=\"refresh\" content=\"0;URL=gallery/index.php\">";
}
else
session_destroy();
echo "<meta http-equiv=\"refresh\" content=\"0;URL=wrong_id.php\">";

i think you need to specify block for "else", i mean:

else {
session_destroy();
echo "<meta http-equiv=\"refresh\" content=\"0;URL=wrong_id.php\">";
}

Not tested.

Link to comment
Share on other sites

Wow, I hate syntax problems.  Especially when it's almost midnight.  Thank you second, and third, and forth sets of eyes.  Working like a charm now.  I hate feeling stupid, but it sure feels good when these problems go away.

Link to comment
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.