PHP Compatibility issue between Firefox and IE....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
btmcbride
Forum Newbie
Posts: 3
Joined: Tue Jun 02, 2009 10:53 am

PHP Compatibility issue between Firefox and IE....

Post 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?
Last edited by califdon on Tue Jun 02, 2009 1:28 pm, edited 1 time in total.
Reason: Edited by moderator to change from code=text to code=php
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

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

Post 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.
btmcbride
Forum Newbie
Posts: 3
Joined: Tue Jun 02, 2009 10:53 am

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

Post 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'
btmcbride
Forum Newbie
Posts: 3
Joined: Tue Jun 02, 2009 10:53 am

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

Post 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?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

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

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

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

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
ornerybits
Forum Newbie
Posts: 18
Joined: Thu May 14, 2009 2:08 pm
Location: Kansas

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

Post 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
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

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

Post 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).
Post Reply