Forum Moderators: coopster
</style>
</head>
<body>
<center>
<header_img><img src=logo.jpg></header_img>
<br><br>
<br><br>
<?php
if (!isset($_POST['empid']))
{
?>
<table border=1 bordercolor=silver cellspacing=0 cellpadding=1 width=700>
<tr><td align=center><br><font face=arial size=1>
<form method="POST" action="register.php">
<br><table><tr><td bgcolor=black width=400 height=30 align=center><font face=arial size=1 color=white><b>Example Company ¦ Employee Login Wizard</td></tr></table><br><br><br>
<font face=arial size=1>Employee ID <input type=text name="empid" size=20><br><br>
<input type="submit" name="s1" value="Continue">
<br>Have Login ID & Password? <a href=login.php> Login Here</a>
</td></tr>
</table>
</form>
<?php
}
else {
$uid = $_POST['empid'];
if (empty($uid))
{ die('<table border=1 bordercolor=silver cellspacing=0 cellpadding=1 width=700>
<tr><td align=center><br><font face=arial size=1>
<form method="post" action="register.php">
<br><table><tr><td bgcolor=black width=400 height=30 align=center><font face=arial size=1 color=white><B>Example Company ¦ Employee Login Wizard</td></tr></table><br><br><br>
Employee ID <input type=text name="empid" size=20>
<br><input type="submit" name="submit" value="Submit">
<br>Have Login ID & Password? <a href=login.php> Login Here</a>
<br></td></tr>
</table><errormsg1><font color=red face=arial size=1><b>Please Enter Registration Code<b></errormsg>');
}
try { $pdo = new PDO('mysql:dbname=example_emp;host=localhost','root','');
}
catch (PDOException $e)
{ die("ERROR: Could not connect: " . $e->getMessage());
}
$uid = $pdo->quote($uid);
$sql = "SELECT COUNT(*) FROM emp_reg_code WHERE emp_registercode = $uid";
if ($result = $pdo->query($sql))
{ $row = $result->fetch();
if ($row[0] == 1)
{ $sql = "SELECT emp_registercode FROM emp_reg_code WHERE emp_registercode = $uid";
if ($result = $pdo->query($sql))
{ $row = $result->fetch();
$uid1 = $row[0];
}
$sql = "SELECT emp_name FROM emp_reg_code WHERE emp_registercode = $uid";
if ($result = $pdo->query($sql))
{ $row = $result->fetch();
$empname = $row[0];
}
$sql = "SELECT emp_designation FROM emp_reg_code WHERE emp_registercode = $uid";
if ($result = $pdo->query($sql))
{ $row = $result->fetch();
$empdesg = $row[0];
}
if(!isset($_POST['t']))
{
?>
<form method="GET" action="register.php">
<table border=1 bordercolor=silver cellspacing=0 cellpadding=1 width=700>
<tr><td align=center><font face=arial size=1>
<br><table><tr><td bgcolor=black width=450 height=30 align=center><font face=arial size=1 color=white><b>Employee Management Wizard ¦ Registration Form</td></tr></table><br>
<table>
<tr><td bgcolor=black width=170 height=23><font face=arial size=1 color=white>Employee's ID</td><td bgcolor=#E8E8E8 ><font face=arial size=2><b><?php echo $uid1 ; ?></td></tr>
<tr><td height=23><font face=arial size=1>Employee Name</td><td><font face=arial size=2><b><?php echo $empname; ?></td></tr>
<tr><td bgcolor=black width=170 height=23><font face=arial size=1 color=white>Employee's Designation</td><td bgcolor=#E8E8E8 ><font face=arial size=2><b><?php echo $empdesg ; ?></td></tr>
<tr><td width=170 height=23><font face="arial" size=1><b>Date of Birth</td><td><Select name="dd"><option>01</option>
<option>31</option></select>
<Select name="mm"><option>01</option><option>12</option></select>
<Select name="yy"><option>1970</option><option>2009</option></select></td></tr>
<tr><td bgcolor=black width=170 height=23><font face=arial size=1 color=white>Login ID</td><td bgcolor=#E8E8E8 ><font face=arial size=2><b><?php echo $uid1 ; ?></td></tr>
<tr><td><font face=arial size=1>Gender</td><td><input type="radio" name="sex" value="male" checked="checked"><font face=arial size=1> Male <input type="radio" name="sex" value="female"> Female</td></tr>
<tr><td bgcolor=black width=170 height=23><font face=arial size=1 color=white>Password</td><td height=20><input type=text name="pass" size=20></td></tr>
<tr><td><font face=arial size=1>Contact No.</td><td><input type=text name=email size=20></td></tr>
<tr><td bgcolor=black width=170 height=23><font face=arial size=1 color=white>Email Address</td><td><input type=text name=email size=20></td></tr>
<tr><td><font face=arial size=1>Current Address</td><td><textarea name="addr" rows="2" cols="24"></textarea></td></tr>
<tr><td bgcolor=black width=170 height=23><font face=arial size=1 color=white>City</td><td><input type=text name=email size=20></td></tr>
</table><br>
<input type="submit" name="t" value="Register Now" > <input type="reset" value="Reset Form Data"><br></td></tr>
</table>
<?php }
else if(isset($_POST['t']))
{ $p=$_POST['pass'];
if(empty($p))
{ die ('empty');
}
}
}
else
{ echo '<table border=1 bordercolor=silver cellspacing=0 cellpadding=1 width=700>
<tr><td align=center><br><font face=arial size=1>
<form method="post" action="register.php">
<br><table><tr><td bgcolor=black width=400 height=30 align=center><font face=arial size=1 color=white><b>Example Company ¦ Employee Login Wizard</td></tr></table><br><br><br>
Employee ID <input type=text name="empid" size=20>
<br><br><br><br>
<input type="submit" name="submit" value="Submit">
<br><br><br>Have Login ID & Password? <a href=login.php> Login Here</a>
<br><br><br><br><br><br><br><br>
</td></tr>
</table><errormsg2><font color=red face=arial size=1><b>Invalid Registration Code<b></errormsg>';
}
}
}
unset($pdo);
?>
</body>
</html>
=======================================================
for database i used phpmyadmin
i have created a database "example_emp"
then table "emp_reg_code" with attributes "emp_registercode", "emp_name", "emp_designation"
i m using wamp server for implemention.
=======================================================
Actually m not getting any error in this code,
when u'll run this code then it will ask for a employee id which is "SCT0001" in my case. when i submit this info, it retrieve data frm database and display name,empid & designation. now it will ask for passwd and other details.
now at this point i wanted to show an error msg when user press the "Register now" button with entering the passwd.
the same thing i did,while entering the employee id previously but this time i'm redirected to the previous page where emp id is asked.
Please help me out in this.
Thanks in advance
Anand
[edited by: coopster at 10:16 am (utc) on Mar. 18, 2009]
[edit reason] no email sigs please and thanks :-) [/edit]
Replace long strings of <br> tags by instead wrapping content in heading, paragraph, and list tags.
Get rid of strings of non-breaking spaces and use CSS to control margins to set positions.
Finally, get rid of the <font> tags and use CSS to set the styles for that content.
The HTML code can be massively simplified here.
Almost every opening <b> tag does not have a matching closing tag. In any case, you can use CSS to set the font-weight for that text.
You should place most of your PHP logic BEFORE the opening <html> tag just in case you have to send more HEADER information out.
"SELECT COUNT(*) FROM emp_reg_code WHERE emp_registercode = $uid") returned nothing or too many rows. If needed, you should break down your script to a more manageable size to find the exact problem. Also, your use of "emp id", "uid", and "register code" seems to mean one entity. Why so many names?