Page 1 of 1

PHP Compatibility issue between Firefox and IE....

Posted: Tue Jun 02, 2009 10:57 am
by btmcbride
Hi guys.

This script I am using works flawlessly in Firefox, however in IE when I enter the correct password it does nothing and simply clears the password field and resets to where I can enter it again. It never goes to the page it is protecting. In Firefox it works great. I enter the password and it take me to the page.

Here is the script:

Code: Select all

 
 
<?php
 
 
$Password = 'testpass'; // Set your password here
 
 
 
/********/
   if (isset($_POST['submit_pwd'])){
      $pass = isset($_POST['passwd']) ? $_POST['passwd'] : '';
     
      if ($pass != $Password) {
         showForm("Incorrect, Try Again.");
         exit();     
      }
   } else {
      showForm();
      exit();
   }
   
function showForm($error="Album LOGIN"){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Album Security</title>
   <link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body><BR /><BR /><BR /><BR /><BR /><BR /><BR /><BR />
    <div id="main">
      <div align="left"></div>
      <div class="caption"><?php echo $error; ?></div>
      <div id="icon">&nbsp;</div>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="pwd">
        Please enter Password:
        <table>
          <tr><td><input class="text" name="passwd" type="password"/></td></tr>
          <tr><td align="center"><br/>
             <input class="text" type="submit" name="submit_pwd" value="Proceed"/>
          </td></tr>
        </table> 
      </form>
      <div id="source">Art of Clarity</div>
   </div>
</body>       
 
<?php   
}
?>
 
 
You guys have any idea how I can get this to work in both firefox and IE?

Re: PHP Compatibility issue between Firefox and IE....

Posted: Tue Jun 02, 2009 12:06 pm
by mikemike
I cannot see how this page would ever forward you to anywhere in any browser. You're not even checking if the password is correct anywhere.

Make sure you're pointing firefox and IE to the same webpage as it sounds to me like you may be uploading to one place and browsing to another. This script doesn't look like it has been complete, you'd need to add an else-statement after the inner-if statement to tell PHP what to do if the password is correct.

Also, as a general rule, functions should always return something.

Re: PHP Compatibility issue between Firefox and IE....

Posted: Tue Jun 02, 2009 12:40 pm
by btmcbride
It works perfectly in firefox. You enter the wrong password and you get en error message and asked to re enter. If you enter the right one it takes you to a page with thumbnails on it.

http://www.artofclarity.org/images/aidenpics/index.php

password is 'testpass'

Re: PHP Compatibility issue between Firefox and IE....

Posted: Tue Jun 02, 2009 12:46 pm
by btmcbride
All this is is a password script. You try to open the above site (pics of my son which I have removed while i try to fix this) the single line of php script on that php document calls the one I pasted above. If you enter the wrong password you are denied entry. If you enter the right one it renders the pictures in the browser.

Question still stands. Why would the above code work flawlessly in Firefox and not at all in IE?

Re: PHP Compatibility issue between Firefox and IE....

Posted: Tue Jun 02, 2009 1:35 pm
by califdon
PHP executes in the web server, before anything is sent to the browser, so PHP doesn't even know (or care) what browser will see the HTML. If the results are different in IE and FF, it is because the HTML is rendered differently. There are numerous issues with your script, including your use of a function for this purpose, and the conflict in your function argument. I am in a hurry and don't have time to even figure out what you were trying to do.

Re: PHP Compatibility issue between Firefox and IE....

Posted: Tue Jun 02, 2009 2:04 pm
by pickle
Usually when there are inconsistencies between browsers, it's because the page isn't being rendered the same - just like ~califdon said. I'd run your code through the HTML validator & get it up to snuff first.

Re: PHP Compatibility issue between Firefox and IE....

Posted: Tue Jun 02, 2009 2:04 pm
by ornerybits
califdon is right. PHP will run the same regardless of browser. If you are getting discrepancies between two browsers (on the same machine - this is important b/c PHP may behave differently on different operating systems), then most likely what is happening is a difference it how the browsers are interpreting the HTML.

Also some browsers are more forgiving than others, meaning that you might have a slight error in your HTML that FF lets you get away with but IE does not. For instance, I noticed that your post didn't have a closing </html> tag. Now I don't think that that would cause the problem you described, but I would look for something similar to be the culprit.

Good luck

Re: PHP Compatibility issue between Firefox and IE....

Posted: Tue Jun 02, 2009 2:20 pm
by mikemike
Well it doesn't work for me in any browser. Ensure you're clearing your cache and checking the right page as well as uploading to the right place. As I said, your script (at least the code you pasted) does not do anything if a password is correct.

I suggest triple checking everything and adding </html> at the base of your function (which has been miss-used).