Forum Moderators: coopster

Message Too Old, No Replies

IE 7 and IE 8 not displaying PHP validation response

         

jnl0225

3:03 pm on Jun 23, 2009 (gmt 0)

10+ Year Member



The script below works perfectly in Firefox and Safari but when I test it in IE 7 or 8 it does show my error codes nor all me to proceed.

<?
// Connect database.
//script removed

//Initialize variables
$username = $_POST['nusername'];
$password = $_POST['npassword'];
$dept = $_POST['ndept'];
$name = $_POST['nname'];
$empid = $_POST['nempid'];
$status = 'No';

$a = $_POST['verifyuser'];

$valid = 0;

// Check matching of username and password.
$result=mysql_query("select * from `accesso1_userdb`.`user` where `username`='".$_POST['nusername']."'");

$message = '';
if (array_key_exists('AddUser', $_POST)) {
if(mysql_num_rows($result)!='0'){ // Find match in database.
$message = '--- The Username ' . $username . ' Already Exist';
}
else if ($valid == 0){
$message = 'Make sure all required fields are filled in. <br />';
if (($username == NULL)¦¦($username == '')){
$message .= 'Enter a username <br />';
}
if (($password == NULL)¦¦($password == '')){
$message .= 'Enter a password <br />';
}
if (($name == NULL)¦¦($name == '')){
$message .= 'Enter the name of the user <br />';
}
if (($dept == '00')¦¦($dept == '')){
$message .= 'Select a department for the user <br />';
}
if ($username != NULL && $password != NULL && $name != NULL && $dept != '00')
{
$message = '';
$valid = 1;
}
}
}
if ( $a == "on" ) {
$asubmit = mysql_query("insert INTO `accesso1_userdb`.`user` values ('$username','$password','$dept','$name','$empid','$status')");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add User</title>

<link href="../scripts/form_style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div align="center" id="useradd">
<br />
<strong>Enter the new user information below.</strong>
<?php if (isset($message)) { echo '<p class="error">'.$message.'</p>'; } ?>
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<table id='form'>
<? if ((array_key_exists('AddUser', $_POST)) && ($valid == 1)) {
if ($a != "on") {
echo "Is this the correct information? If not, correct
<br /> the information, click the confirmation box and submit.<br />";
?>
<input type="checkbox" name="verifyuser" /> I confirm that this information is correct <br />;
<?
}
else {
echo "The user profile for " . $name . " has been added to the database <br />";
}
}
?>
<br />

<tr>
<td>Full Name : </td>
<td><input name="nname" type="text" id="name" <? if ($name != ''){ ?>value="<? echo $name; ?>" <? }?> /></td>
</tr>
<tr>
<td>Username : </td>
<td><input name="nusername" type="text" id="username" <? if ($username != ''){ ?>value="<? echo $username; ?>" <? }?> /></td>
</tr>
<tr>
<td>Password : </td>
<td><input name="npassword" type="password" id="password" <? if ($password != ''){ ?>value="<? echo $password; ?>" <? }?> /></td>
</tr>
<tr>
<td>Department : </td>
<td><select name="ndept" id="dept">
<option selected="selected" value="00">-- Choose option --</option>
<option <? if ($dept == 'admin'){ ?> selected="selected" <? } ?> value="admin">admin</option>
<option <? if ($dept == 'finance'){ ?> selected="selected" <? } ?> value="finance">finance</option>
<option <? if ($dept == 'manager'){ ?> selected="selected" <? } ?> value="manager">manager</option>
<option <? if ($dept == 'sales'){ ?> selected="selected" <? } ?> value="sales">sales</option>
<option <? if ($dept == 'service'){ ?> selected="selected" <? } ?> value="service">service</option>
<option <? if ($dept == 'vendor'){ ?> selected="selected" <? } ?> value="vendor">vendor</option>
</select>
</td>
</tr>
<tr>
<td>Employee ID : </td>
<td><input name="nempid" type="text" id="empid" <? if ($empid != ''){ ?>value="<? echo $empid; ?>" <? } else { ?>value="<? $random = rand(1,99999); echo $random; ?>"<? } ?> /></td>
</tr>
<tr>
<td colspan="2" align="center">
<? if ($a == "on") { ?>
<a href='useradd.php' style='text-decoration: none;'><img src='../images/next_button.jpg'></a><? }
else { ?>
<input name="AddUser" type="image" src="../images/next_button.jpg" id="AddUser" value="Submit" />
<? } ?>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>

jatar_k

3:07 pm on Jun 23, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I assume every parameter is the same, the only difference is the browser, just make sure you aren't doing anything different.

if you view source in IE what do you get?

jnl0225

3:23 pm on Jun 23, 2009 (gmt 0)

10+ Year Member



I've provide the view source information for both IE and Firefox below. From the look of things they both return the same data.

IE view source
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add User</title>

<link href="../scripts/form_style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div align="center" id="useradd">
<br />
<strong>Enter the new user information below. <br />
<br />
</strong>
<p class="error"></p> <form id="form1" name="form1" method="post" action="">
<table id='form'>
<br />

<tr>
<td>Full Name : </td>
<td><input name="nname" type="text" id="name" /></td>
</tr>
<tr>
<td>Username : </td>
<td><input name="nusername" type="text" id="username" /></td>
</tr>
<tr>
<td>Password : </td>
<td><input name="npassword" type="password" id="password" /></td>
</tr>
<tr>
<td>Department : </td>
<td><select name="ndept" id="dept">
<option selected="selected" value="00">-- Choose option --</option>
<option value="admin">admin</option>
<option value="finance">finance</option>
<option value="manager">manager</option>
<option value="sales">sales</option>
<option value="service">service</option>
<option value="vendor">vendor</option>
</select>
</td>
</tr>
<tr>
<td>Employee ID : </td>
<td><input name="nempid" type="text" id="empid" value="12865" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="AddUser" type="image" src="../images/next_button.jpg" id="AddUser" value="Submit" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>

Firefox view source
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add User</title>

<link href="../scripts/form_style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div align="center" id="useradd">
<br />

<strong>Enter the new user information below. <br />
<br />
</strong>
<p class="error"></p> <form id="form1" name="form1" method="post" action="">
<table id='form'>
<br />

<tr>
<td>Full Name : </td>

<td><input name="nname" type="text" id="name" /></td>
</tr>
<tr>
<td>Username : </td>
<td><input name="nusername" type="text" id="username" /></td>
</tr>
<tr>
<td>Password : </td>

<td><input name="npassword" type="password" id="password" /></td>
</tr>
<tr>
<td>Department : </td>
<td><select name="ndept" id="dept">
<option selected="selected" value="00">-- Choose option --</option>
<option value="admin">admin</option>

<option value="finance">finance</option>
<option value="manager">manager</option>
<option value="sales">sales</option>
<option value="service">service</option>
<option value="vendor">vendor</option>
</select>

</td>
</tr>
<tr>
<td>Employee ID : </td>
<td><input name="nempid" type="text" id="empid" value="43850" /></td>
</tr>
<tr>
<td colspan="2" align="center">

<input name="AddUser" type="image" src="../images/next_button.jpg" id="AddUser" value="Submit" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>

[edited by: eelixduppy at 1:54 am (utc) on June 24, 2009]
[edit reason] removed URL [/edit]

jatar_k

3:44 pm on Jun 23, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



we don't allow posting urls but I did look first, it works in IE for me, looks exactly the same

jnl0225

4:22 pm on Jun 23, 2009 (gmt 0)

10+ Year Member



Are the error messages displaying after clicking the "Next" button. That's the problem.

jatar_k

4:42 pm on Jun 23, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



they don't in IE actually, so you more than likely have an html issue, not php

the first thing would be to add a value to your form action here

<form id="form1" name="form1" method="post" action="">

it's blank, meaning any browser is forced to assume what you meant, my guess is IE assumes you meant none where th others assume you meant self