UPDATE Query is MySql using PHP ?


After creating a table with required fields in a database we need to update information into it, for that we use a update query to update the information of a form into the database table in MySql.

Updating information on the page.

we need to create a page for entering values in the table.(update.php)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>form page</title>
</head>
<body>
    <form name="f" method="POST" action="update_action.php">
Enter name<input type="text" name="t1"><br>
Enter roll<input type="number" name="t2"><br>
<input type="submit">
</form>
</body>
</html>

Updating information in the database table.

Connectivity page for inserting values in the database.(update_action.php)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Connectivity Page</title>
</head>
<body>
<?php
  $n=$_REQUEST["t1"];
  $r=$_REQUEST["t2"];
  $servername="localhost";
  $username="root";
  $password="";
  $db="project";   */suppose project is our database name. */
  $conn=mysqli_connect($servername,$username,$password,$db);
  if(!$conn)
  {
   echo"not connected";
  }
  $q="UPDATE `table1` SET `name`='$n' WHERE roll='$r'";  */ suppose table1 is our table name. */
  $qu=mysqli_query($conn,$q);
  ?>
</body>
</html>