Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

Recommended Posts

Hi Freaks,

 

I thought about taking a club to some of the boys at MS for constantly pissing me off but I thought I'd give this a chance first.

 

Anyway, this page runs fine on my computer locally and on my server with Firefox.  It also runs fine with IE7 locally on my computer, however the log in attempt fails when trying to do so with IE7 on my server.

 

It is redirected by the first header, and takes me to the index.php page, but the session variables return false, displaying the index.php page as normal.

 

I have made a check adding an else after the if(isset($_SESSION['USERNAME']) == TRUE) { } bit, and it returns false.

 

Again, this problem only occurs in IE7.  Simple script too. >:(

 

Here is my login.php

 

<?php
session_start();
require('db.php');

if($_POST['submit']) {
$sql = "SELECT * FROM logins WHERE username = '".$_POST['username']."'
		AND password = '".$_POST['password']."';";
$result = mysql_query($sql) or die(mysql_error());
$numrows = mysql_num_rows($result);

if($numrows == 1) {
$row = mysql_fetch_assoc($result);
session_register("USERNAME");
session_register("USERID");

$_SESSION['USERNAME'] = $row['username'];
$_SESSION['USERID'] = $row['id'];

header("Location: " . $con_dir . "/index.php");
exit();
}

else {
header("Location: " . $con_dir . "/login.php?error=1");
exit();
}
}
else {
require('header.php');

if($_GET['error']) {
	echo "Incorrect login, please try again!";
}
}
?>

<form action="<?php echo $SCRIPT_NAME; ?>" method="post">

<table>
<tr>
<td><strong>Username</strong></td>
<td><input type="text" name="username" style="background:#eeeeee"></td>
</tr>
<tr>
<td><strong>Password</strong></td>
<td><input type="password" name="password" style="background:#eeeeee"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Login!"></td>
</tr>
</table>

</form>

<?php
require('footer.php');
?>

 

Here is my index.php

<?php
session_start();
require('db.php');
require('header.php');

echo "<table><tr><td valign='top'>";
echo "<img src='name.jpg' style='border: none;'></td>
		<td valign='top' align='right'><h3><a href='form.php'>Contact</a></h3>";
echo "</td></tr><tr><td colspan='3'><hr></td></tr><tr>";

$catsql = "SELECT * FROM categories;";
$catresult = mysql_query($catsql);

while($catrow = mysql_fetch_assoc($catresult)) {

$sql = "SELECT * FROM gallery WHERE cat_id = " . $catrow['id'] . " ORDER BY RAND() LIMIT 1;";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);

if ($i == 2)
{
	print '</tr><tr>';
	$i = 0;
}
$i++;

echo "<td> ";
echo "<strong><a href='gallery.php?id=" . $catrow['id'] . "'>" . $catrow['cat'] . "</strong><br>";
echo "<img src='./art/".$row['image']."' width='250' height='250'></a>";

if(isset($_SESSION['USERNAME']) == TRUE) {
	echo "<br>[<a href='deletecategory.php?id=".$catrow['id']."'><strong>Delete Gallery</strong></a>]    ";
}
echo "</td>";
}
if(isset($_SESSION['USERNAME']) == TRUE) {
	echo "<tr><td colspan='3'><hr></td></tr>";
	echo "<tr><td><strong>Welcome XXX!</strong></td></tr>";

	echo "<tr><td><strong>[<a href='category.php'>Add a category</a>]</strong></td>";
	echo "<td><strong>[<a href='newitem.php'>Add an item</a>]</strong></td></tr>";

	echo "<tr><td><strong>[<a href='contact.php'>Messages</a>]</strong></td>";
	echo "<td><strong>[<a href='logout.php'>Logout</a>]</strong></td></tr>";
}
echo "</table>";

require('footer.php');

?>

 

Thanks for reading.

Link to comment
https://forums.phpfreaks.com/topic/148409-ie7-header-session-problem/
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.