This is my problem, I'm trying to do some very basic learning of php and sql on my own. I've been doing alright so far on my own, but I have come upon one problem that I can't figure out on my own. I created a few simple pages where the someone can create an account, login, then edit any information they previously entered, then a logout page. Everything works just fine in ie7 and firefox. However I have problems with ie6 and lower. On the first page and the login page, in ie6, after hitting the submit/login button, it just returns a blank page. If I hit refresh, it then displays the page just like it was supposed to in the first place. Both the form and the login in page is where I start sessions, so its probably somehow related to this. How I go about fixing this, I have no idea.
Is this a problem with the way I coded it in php? Related to some of my servers php.ini config settings? Is this not related to php at all, and just another bug with ie that I can't fix at all? Even if this turns out not to be wholly php related, ANY information or direction you could give me would be very, very helpful.
Code and links to pages below:
http://www.ryancolantuono.com/form.php
http://www.ryancolantuono.com/login.php
http://www.ryancolantuono.com/main.php
Form page code:
<?php
$errorMessage = '';
if ($_POST['submit'] == "Submit")
{
//Determine if a Name was entered
$valid_form = true;
if ($_POST['username'] == "")
{
$errorMessage = 'Enter your name. ';
$valid_form = false;
}
else
{
$name = $_POST['username'];
}
if ($_POST['password'] == "")
{
$errorMessage = 'Enter a password. ';
$valid_form = false;
}
elseif (strlen($_POST['password']) < 4)
{
$errorMessage = 'Password must contain at least 4 characters. ';
$valid_form = false;
}
else
{
$password = $_POST['password'];
}
if ($_POST['password2'] == "")
{
$errorMessage = 'Enter password a second time. ';
$valid_form = false;
}
elseif (strlen($_POST['password2']) < 4)
{
$errorMessage = "Password must contain at least 4 characters. ";
$valid_form = false;
}
else
{
$password = $_POST['password2'];
}
//if all form fields were submitted properly, begin processing
if($valid_form == true)
{
$username=$_POST['username'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$email=$_POST['email'];
$name=$_POST['name'];
$zip=$_POST['zip'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$adress=$_POST['adress'];
$phone=$_POST['phone'];
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db(db) or die(mysql_error());
// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM test WHERE username = '$username'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
$errorMessage = 'Sorry, the username '.$_POST['username'].'
is already in use, please go back and create another user name. ';
}
//checks to make sure both passwords match
if ($_POST['password'] != $_POST['password2']) {
$errorMessage = 'Your passwords did not match. ';
}
mysql_query("INSERT INTO `test` VALUES ('$username', '$password', '$email', '$name',
'$zip', '$city', '$state','$country', '$adress', '$phone')") or die(mysql_error());
$to = $_POST['email'];
$subject = "Form Demo";
$headers = "Hello $name,
Username: $username
Password: $password
Zip Code: $zip
City: $city
State: $state
Country: $country
Address: $adress
Phone: $phone
Thanks!";
$sent = mail($to, $subject, $headers);
if($sent){
header('Location: http://www.ryancolantuono.com/login.php');
}
else{
$errorMessage = 'We encountered an error sending your mail. '; }
mysql_close();
}
}
?>
<!-- -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="css/form.css" type="text/css" />
<script type="text/javascript" src="js/emailcheck.js"></script>
<title>Form Demo</title>
</head>
<body>
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="#990000"><?php echo $errorMessage;
?></font></strong></p>
<?php
}
?>
<form id="demo" onsubmit="return validate_form(this);" method="post"
action ="<? $_SERVER['PHP_SELF']?>">
<table width="100%" class="shell" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" class="inside" cellpadding="0" cellspacing="1">
<tr>
<td class="tdheader" colspan="2">
Account Creation
</td>
</tr>
<tr>
<td colspan="2" class="header">
Enter information here to create an account for this form demo.
<br />
<br />
</td>
</tr>
<tr>
<td class="main" width="50%">
Username
</td>
<td class="main" valign="top">
<input type="text" name="username" class="input" size="32" value="<?php echo $_POST['username'];?>" /> *
</td>
</tr>
<tr>
<td class="main" width="50%">
Password
</td>
<td class="main" width="50%">
<input type="password" name="password" class="input" size="32" /> *
</td>
</tr>
<tr>
<td class="main" width="50%">
Verify Password
</td>
<td class="main" width="50%">
<input type="password" name="password2" class="input" size="32" /> *
</td>
</tr>
<tr>
<td class="main" width="50%">
Your Email
</td>
<td class="main" valign="top">
<input type="text" name="email" size="32" class="input" value="<?php echo $_POST['email'];?>" /> *
</td>
</tr>
<tr>
<td class="main" width="50%">
Your Full Name
</td>
<td class="main" valign="top" width="50%">
<input type="text" name="name" size="32" class="input" value="<?php echo $_POST['name'];?>" />
</td>
</tr>
<tr>
<td class="main" width="50%">
Your Zip Code
</td>
<td class="main" valign="top">
<input type="text" name="zip" size="5" maxlength="5" class="input" value="<?php echo $_POST['zip'];?>" />
</td>
</tr>
<tr>
<td class="main" width="50%">
Your City
</td>
<td class="main" valign="top">
<input type="text" name="city" size="32" class="input" value="<?php echo $_POST['city'];?>"
</td>
</tr>
<tr>
<td class="main" width="50%">
State/Province
</td>
<td class="main" valign="top">
<input type="text" name="state" size="32" class="input" value="<?php echo $_POST['state'];?>"
</td>
</tr>
<tr>
<td class="main" width="50%">
Country
</td>
<td class="main" valign="top">
<input type="text" name="country" size="32" class="input" value="<?php echo $_POST['country'];?>"
</td>
</tr>
<tr>
<td class="main" width="50%">
Address
</td>
<td class="main" valign="top">
<input type="text" name="adress" size="32" class="input" value="<?php echo $_POST['adress'];?>"
</td>
</tr>
<tr>
<td class="main" width="50%">
Phone
</td>
<td class="main" valign="top">
<input type="text" name="phone" size="32" class="input" value="<?php echo $_POST['phone'];?>"
</td>
</tr>
<tr>
<td colspan="2" class="main" align="left">
Fields with a * next to them are required.
</td></tr>
<tr>
<td colspan="2" class="main" align="center">
<input type="submit" name="submit" value="Submit" class="button" />[CODE]
</td></tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
[/code]