Jump to content

Php IE 7 help


misheck

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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>

 

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.