-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhome.php
More file actions
103 lines (92 loc) · 2.89 KB
/
home.php
File metadata and controls
103 lines (92 loc) · 2.89 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<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
$servername = "tetranoodle.cksjypy9h04e.us-east-1.rds.amazonaws.com";
$username = "tetranoodle";
$password = "tetranoodle";
$dbname = "tetranoodle";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT id, username, psd FROM tbllogin";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo " ID :{$row['id']} <br> ".
" NAME : {$row['username']} <br> ".
" PASSW : {$row['psd']} <br> ".
"--------------------------------<br>";
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
</body>
</html>