Forum Moderators: coopster
<?
// 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>
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]
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