-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathhome.php
88 lines (82 loc) · 2.61 KB
/
home.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<html>
<title>Simple Database Application using PHP</title>
<h1>Simple Database Application using PHP</h1>
<script type="text/javascript">
function validateForm()
{ var un=document.form1.username.value;
var pd=document.form1.psd.value;
if(un=="" && pd!="")
{
document.getElementById("errorMessage").innerHTML="Please enter username";return false; }
if(un!="" && pd=="")
{ document.getElementById("errorMessage").innerHTML="Please enter password"; return false; }
if(un=="" && pd=="")
{ document.getElementById("errorMessage").innerHTML="Please enter username & password";return false; }
}
</script>
<body>
<?PHP
if($_REQUEST['action']=='edit')
{
?>
<form id="form1" name="form1" method="post" action="update.php?id=<?PHP echo $_REQUEST['id']; ?>" onSubmit="return validateForm();">
<table width="200" border="1">
<tr>
<td>Username</td>
<td><label for="username"></label>
<input type="text" name="username" id="username" value="<?PHP echo $_REQUEST['un']; ?>" /></td>
</tr>
<tr>
<td>Password</td>
<td><label for="psd"></label>
<input type="text" name="psd" id="psd" value="<?PHP echo $_REQUEST['pd']; ?>" /></td>
</tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
<td><input type="reset" name="Reset" id="Reset" value="Reset" /></td>
</tr>
</table>
</form>
<?PHP
}
else
{
?>
<form id="form1" name="form1" method="post" action="insert.php" onSubmit="return validateForm();">
<table width="200" border="1">
<tr>
<td>Username</td>
<td><label for="username"></label>
<input type="text" name="username" id="username" value="" /></td>
</tr>
<tr>
<td>Password</td>
<td><label for="psd"></label>
<input type="text" name="psd" id="psd" value="" /></td>
</tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
<td><input type="reset" name="Reset" id="Reset" value="Reset" /></td>
</tr>
</table>
</form>
<?PHP } ?>
<p id="errorMessage" style="color:#C00; font-style:italic;"></p>
<?php
require_once('conn.php');
$result = mysql_query("SELECT * FROM tbllogin");
echo "<table border='2'>";
echo "<th>Username</th><th>Password</th>";
while($row=mysql_fetch_array($result))
{ echo "<tr>";
$idn=$row['id'];$un=$row['username'];$pd=$row['psd'];
echo "<td>".$row['username']." </td>";
echo "<td>".$row['psd']."</td>";
echo "<td><a href='delete.php?id=$idn'>Delete</a></td>
<td><a href='home.php?id=$idn&action=edit&un=$un&pd=$pd'>Edit</a></td>";
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>