-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewStudent.php
92 lines (90 loc) · 3.06 KB
/
viewStudent.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
89
90
91
92
<?php
$name=$rollno=$dept=$email=$address=$aboutme="";
$Ename=$Edept=$Eemail=$Erollno=$Eaddress="";
$pwd="";
$servername="localhost";
$username="joy";
$password="password";
$dbname="mydb";
$conn=new mysqli($servername,$username,$password,$dbname);
if($conn->connect_error)
{
die("Connection Failed: ".$conn->connect_error)."<br>";
}
else
{
echo "Connected!<br>";
}
$disabled="disabled";
$rollno="";
if($_SERVER["REQUEST_METHOD"]=="GET")
{
$rollno=$_GET["rollno"];
$error="";
$length=strlen($rollno);
if(!preg_match("/^[0-9]*$/",$rollno) || strlen($rollno)!=9)
{
$error="Wrong rollno";
}
else
{
$sql="SELECT * FROM student
WHERE Rollno='$rollno';";
$out=$conn->query($sql);
if($out->num_rows==0)
{
$error="NO such entry";
}
else
{
$disabled="";
$row=$out->fetch_assoc();
echo "Name:".$row["Name"]."<br>Rollno: ".$row["Rollno"]."<br>Department: ".$row["Department"]."<br>Email:".$row["Email"]."<br>Address: ".$row["Address"]."<br>About me:".$row["Aboutme"];
}
}
}
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body{
font-family: "Comic Sans MS";
}
span{
color:red;
font-family: "Times New Roman";
}
input[type=text]{
border: 1px solid grey;
border-radius: 5px;
padding: 5px;
}
form textarea{
border: 1px solid grey;
border-radius: 5px;
font-family: 'Comic Sans MS';
}
select{
padding: 5px;
border-radius:5px;
font-size: 15px;
}
input[type=submit]{
padding: 5px;
border-radius:5px;
font-size: 20px;
cursor: pointer;
outline: none;
}
</style>
</head>
<body>
<br><br><form method="get" action="<?php echo $_SERVER["PHP_SELF"];?>">
RollNo:<input type="text" name="rollno" value="<?php echo $rollno;?>"><span>*<?php echo $error;?></span><br><br>
<input type="submit"><br><br>
<button type="submit" formaction="viewStudentSubmit.php" <?php echo $disabled;?>>EDIT</button>
</form>
</body>
</html>