Advertisement
Guest User

php update api

a guest
Apr 13th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2.     $host="localhost"; //replace with database hostname
  3.     $username="username"; //replace with database username
  4.     $password="attendance"; //replace with database password
  5.     $db_name="db_name"; //replace with database name
  6.     $con=mysql_connect("$host", "$username", "$password") or die ("cannot connect");
  7.     mysql_select_db("$db_name") or die ("cannot select DB");
  8.     $matric = $_POST['matric'];
  9.     $mac = $_POST['mac'];
  10.     $sql = "update students set `mac` = '$mac' WHERE `matric` = $matric";
  11.     if(mysql_query($sql)){
  12.         echo 'success';
  13.     }
  14.     else{
  15.         echo 'failure';
  16.     }
  17.     mysql_close($con);
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement