1 <html>
2 <body>
3 <form action="" method="post">
4 Enter Reg No to be updated<input type="text" name="x"></br>
5 Enter New Age<input type="text" name="age"></br>
6 <input type="submit" value="Search"><input type="reset" value="clear">
7 </form>
8 </body></html>
9
10 <?php
11 $servername='localhost';
12 $username='root';
13 $password="";
14 $dbname='bsc';
15
16 $conn = mysqli_connect($servername, $username, $password,$dbname);
17
18 if (!$conn)
19 {
20 die("Connection failed:".mysqli_connect_error());
21 }
22 else if($_SERVER['REQUEST_METHOD']=="POST")
23 {
24 $regno=$_POST['x'];
25 $new_age=$_POST['age'];
26
27 $sql = "UPDATE student set age='$new_age' WHERE regNo='$regno'";
28 $result = mysqli_query($conn, $sql);
29
30 if ($result)
31 {
32 if (mysqli_affected_rows($conn) > 0) {
33 echo "<h3>Update successful for Reg No: $regno</h3>";
34 } else {
35 echo "<h3>No record found with Reg No: $regno</h3>";
36 }
37 }
38
39 }
40 . uytre
41 ;LKJ X C
42 +
43 >
44