misheck Posted October 18, 2008 Share Posted October 18, 2008 I am just starting out on PHP and I have a laptop configured with Xampp meaning I have PHP, Apache, Mysql and MyPhpadmin installed. I have IE7 and firefox installed. My problem is that I am trying out a php script I have written which has a login and submit button. When I click the submit button in IE7 nothing happens but when I use firefox I am able to login. My test server is the same laptop so its running on localhost. I have tried adding 127.0.0.1 and localhost to the trusted site and also to intranet site but nothing has changed. I know my script is OK because its working well on Firefox so the problem is to do with IE7. I dont think the session is using any cookies and also even if it was the submit button would work still and the message displayed for the incorrect login details displayed. Any suggestions to get my php script work on IE7. I will post the srcipt if its relevant to troubleshoot the problem. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 18, 2008 Share Posted October 18, 2008 please post the code so we can see how it is being used Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 18, 2008 Share Posted October 18, 2008 I'd probably have to go on a limb and say your form HTML is bad. >_> Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 18, 2008 Share Posted October 18, 2008 PHP only outputs what you tell it to. PHP has nothing to do with browsers. The only thing that differs from browser to browser is how it interprets your HTML and CSS. As DarkWater stated, the problem is probably in your HTML output but we can't know for sure without looking at your code (obviously). Quote Link to comment Share on other sites More sharing options...
jordanwb Posted October 18, 2008 Share Posted October 18, 2008 Did you start the Apache server? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 18, 2008 Share Posted October 18, 2008 Did you start the Apache server? Obviously. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 18, 2008 Share Posted October 18, 2008 I'm going to guess its' an image submit button - http://us2.php.net/manual/en/faq.html.php#faq.html.form-image Quote Link to comment Share on other sites More sharing options...
misheck Posted October 18, 2008 Author Share Posted October 18, 2008 Here is the login code: <?php session_unset(); ?> <html> <head> <title>Please Log In</title> </head> <body> <?php include "header.php"; ?> <form method="post" action="movie1.php"> <p>Enter your username: <input type="text" name="user"> </p> <p>Enter your password: <input type="password" name="pass"> </p> <input type="submit" name="Submit" value="Submit"> </p> </form> <?php include "footer.php"; ?> </body> </html> and here is the link to the site after the submit button <?php session_start (); //check to see if user has logged in with a valid password if ($_SESSION['authuser']!=1) { echo "Sorry but you don't have permission to view this page, you looser!"; exit(); } ?> <html> <head> <title>My Movie Site- <?php echo $_REQUEST['favmovie']; ?></title> </head> <body> <?php include "header.php"; ?> <?php $favmovies = array("Life of Brian", "Stripes", "Office Space", "The Holy Grail", "Matrix", "Terminator 2", "Star Wars", "Close encounters of the Third Kind", "Sixteen Candles", "Caddyshack"); //end of deleted lines if (isset($_REQUEST['favmovie'])) { echo "Welcome to our site, "; //delete this line: echo $_COOKIE['username']; echo $_SESSION['username']; echo "! <br>"; echo "My favorite movie is "; echo $_REQUEST['favmovie']; echo "<br>"; $movierate = 5; echo "My Movie rating for this movie is : "; echo $movierate; } else { echo "My Top ". $_POST["num"] . " movies are:<br>"; if (isset ($_REQUEST['sorted'])) { sort($favmovies); } //list the movies $numlist = 1; while ($numlist <= $_POST["num"]) { echo $numlist; echo ". "; echo pos($favmovies); next($favmovies); echo "<br>\n"; //changed this $numlist = $numlist + 1; } } ?> <?php include "footer.php"; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
misheck Posted October 18, 2008 Author Share Posted October 18, 2008 I dont think my problem is to do with the code but it might have something to do with IE7 because the same code works firefox. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 18, 2008 Share Posted October 18, 2008 try in your first if statement to check for not empty or !empty variable. tell me if this solves it or not Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 18, 2008 Share Posted October 18, 2008 Other than a missing <p> tag, the posted form code works in IE7. Your header.php and to a lesser extent footer.php could be doing something that causes the HTML to be invalid. Some browsers ignore HTML errors but other browsers don't. It would take posting all the code that makes up the page the form in on or providing a link if this is on a public server. The second piece of posted code is not your login code because the first thing it does is to check if you are already logged in, it is not actually doing the logging in. After you make sure there are absolutely no problems in the form, the first troubleshooting step is to display exactly what $_POST data is received by your form processing code. There are other possible reasons, such as register_globals are on and you have a cookie set in one browser but not the other with the same name as a form field and the cookie value overwrites the form data. Or maybe you already have a session established in one browser and are already logged in, but not the other browser and your login code has a problem. Quote Link to comment Share on other sites More sharing options...
misheck Posted October 18, 2008 Author Share Posted October 18, 2008 The code has never worked with IE7 before and after I added the header and footer. I have only added them because I could not afford to hold my studies over this but I am just interested in knowing why its not working so I can use IE7 for test site. In reply to darkfreaks I dont know how and where to add the if statement. I have also checked that the registers_global is off and I have tried opening and starting a new session but that has not helped either. Try the code with header and footer removed and see if you the submit button works. I have tried adding <p> but that has not helped either. I am just surprised the submit button works in firefox and safari without any issues and in IE7 it just doesnt do anything. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 18, 2008 Share Posted October 18, 2008 What is the relevance between the two blocks of code you posted. I cannot seem to see any relevance. You should also post what the code is supposed to do. What the code is doing now, rather than saying it doesn't work. Quote Link to comment Share on other sites More sharing options...
misheck Posted October 18, 2008 Author Share Posted October 18, 2008 The submit button does not work in IE7. The first code is the one with the login code and page. The second code is the link you are sent to after entering the correct username and password. I have posted the missing code below. <?php //delete this line: setcookie ('username', 'Joe',time()+60); session_start(); $_SESSION['username'] = $_POST['user']; $_SESSION['userpass'] = $_POST ['pass']; $_SESSION['authuser'] = 0; //Check username and password information if (($_SESSION['username'] == 'Joe') and ($_SESSION ['userpass'] == '12345')) { $_SESSION['authuser'] = 1; }else{ echo "Sorry, but you dont have permission to view this page, you looser!"; exit(); } ?> <html> <head> <title>Find my Favorite Movie!</title> </head> <body> <?php include "header.php"; ?> <p>Enter your font choice : <select name="font"> <option value="Verdana">Verdana</option> <option value="Arial">Arial</option> <option value="Times New Roman">Times New Roman</option> </select> </p> <p>Enter your font size: <select name="Size"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </p> <select name="menu"> <option value="black">Black</option> <option value="red">Red</option> <option value="green">Green</option> <option value="purple">Purple</option> </select> </p> <?php //add this line: $myfavmovie = urlencode("Life of Brian"); //change this line; echo "<a href='moviesite.php?favmovie=$myfavmovie'>"; echo "Click here to see information about my favorite movie!"; echo "</a>"; echo "<br>"; //change the following line: echo "Or choose how many movies you would like to see:"; echo "</a>"; echo "<br>"; ?> <form method="post" action="moviesite.php"> <p>Enter number of movies (up to 10) <input type="text" name="num"> <br> check here if you want the list sorted alphabetically: <input type="checkbox" name="sorted"> </p> <input type="submit" name="Submit" value="submit"> </form> <?php include "footer.php"; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 18, 2008 Share Posted October 18, 2008 if(isset($_REQUEST['favmovie'])){} change TO: if(isset($_REQUEST['favmovie'])||!empty($_REQUEST['favmovie'])){ Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 18, 2008 Share Posted October 18, 2008 I have tested your code in IE7 and it works fine for me. Quote Link to comment Share on other sites More sharing options...
misheck Posted October 18, 2008 Author Share Posted October 18, 2008 I have tried adding the if statement but when I click the submit button nothing happens at all. In firefox it carries on working OK. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 18, 2008 Share Posted October 18, 2008 What happens if you remove the following line in login.php (apart from the header disappearing) <?php include "header.php"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.