daily pastebin goal
73%
SHARE
TWEET

Untitled

a guest Mar 20th, 2017 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $servername = "";
  3. $username = "";
  4. $password = "";
  5. $dbname = "";
  6.  
  7.         // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11.     die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. $UID = (int)$_GET['StaffID'];
  15.  
  16.  
  17.  
  18. $sql ="SELECT * FROM staff WHERE StaffID = '$UID'"
  19.      or die(mysqli_error());
  20.  
  21. if(mysqli_num_rows($sql)>=1){
  22.     while($row = mysqli_fetch_array($query)) {
  23.         $Name = $row['Name'];
  24.         $surname = $row['Address'];
  25.         $FBID = $row['Telephone'];
  26.         $IMGNU = $row['BusinessID'];
  27.     }
  28. ?>
  29.  
  30. <form action="update.php" method="post">
  31.  
  32. <input type="hidden" name="ID" value="<?=$UID;?>"><br>
  33. Name: <input type="text" name="Name" value="<?=$Name?>"><br>
  34. Address: <input type="text" name="Address" value="<?=$Address?>"><br>
  35. Telephone: <input type="text" name="Telephone" value="<?=$Telephone?>"><br>
  36. BusinessID: <input type="text" name="BusinessID" value="<?=$BusinessID?>"><br>
  37.  
  38. <input type="Submit">
  39. </form>
  40. <?php
  41. }else{
  42.     echo 'No entry found. <a href="javascript:history.back()">Go back</a>';
  43. }
  44. ?>
  45.    
  46. <?php
  47. $servername = "";
  48. $username = "";
  49. $password = "";
  50. $dbname = "";
  51.  
  52.         // Create connection
  53. $conn = new mysqli($servername, $username, $password, $dbname);
  54. // Check connection
  55. if ($conn->connect_error) {
  56.     die("Connection failed: " . $conn->connect_error);
  57. }
  58.  
  59.     $StaffID= (int)$_POST["StaffID"];
  60.  
  61.    $Name = $conn->real_escape_string($_REQUEST['Name']);
  62. $Address = $conn->real_escape_string($_REQUEST['Address']);
  63. $Telephone= $conn->real_escape_string($_REQUEST['Telephone']);
  64. $BusinessID = $conn->real_escape_string($_REQUEST['BusinessID']);
  65.  
  66.  
  67.     $query="UPDATE staff
  68.             SET Name = '$Name', Address = '$Address', FBID = '$Telephone'
  69.             WHERE ID='$StaffID";
  70.  
  71.  
  72. mysqli_query($query)or die(mysqli_error());
  73. if(mysqli_affected_rows()>=1){
  74.     echo "<p>($ud_ID) Record Updated<p>";
  75. }else{
  76.     echo "<p>($ud_ID) Not Updated<p>";
  77. }
  78. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top