daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Dec 6th, 2016 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. // PHP code to update data from MySQL database table
  4.  
  5. if(isset($_POST['update']))
  6. {
  7.  
  8.    $hostname = "localhost";
  9.    $username = "root";
  10.    $password = "";
  11.    $databaseName = "winc sports";
  12.  
  13.    $connect = mysqli_connect($hostname, $username, $password, $databaseName);
  14.  
  15.    // get values form input text and number
  16.  
  17.    $id = $_POST['Id'];
  18.    $fname = $_POST['Fname'];
  19.    $lname = $_POST['Lname'];
  20.    $age = $_POST['Age'];
  21.    $country=$_POST['Nationality'];
  22.     $phone=$_POST['PhoneNumber'];
  23.     $email=$_POST['Email'];
  24.  
  25.    // mysql query to Update data
  26.    $query = "UPDATE `students` SET `Fname`='" . $fname . "',`Lname`='" . $lname . "',`Nationality`='" . $country . "',`PhoneNumber`=" . $phone . ",`Email`='".$email."',`Age`= " . $age . " WHERE `Id` = '" . $id . "'";
  27.  
  28.    $result = mysqli_query($connect, $query);
  29.  
  30.    if($result)
  31.    {
  32.        echo 'Data Updated';
  33.    }else{
  34.        echo 'Data Not Updated';
  35.    }
  36.    mysqli_close($connect);
  37. }
  38.  
  39. ?>
  40.  
  41. <!DOCTYPE html>
  42.  
  43. <html>
  44.  
  45.     <head>
  46.  
  47.         <title>PHP INSERT DATA USING PDO</title>
  48.  
  49.         <meta charset="UTF-8">
  50.  
  51.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  52.  
  53.     </head>
  54.     <body>
  55.         <form action="updating.php" method="post">
  56.     <input type="text" name="id"  placeholder="Enter new ID"><br><br>
  57.     <input type="text" name="fname"  placeholder="Enter new First Name"><br><br>
  58.     <input type="text" name="lname"  placeholder="Enter new Last Name"><br><br>
  59.     <input type="number" name="age"  placeholder="Enter new age" min="13" max="90"><br><br>
  60.     <input type="text" name="country"  placeholder="Enter new Nationality"><br><br>
  61.     <input type="number" name="phone"  placeholder="Enter new Phone Number"><br><br>
  62.     <input type="text" name="email"  placeholder="Enter new Email"><br><br>
  63.     <input type="submit" name="update" value="update">
  64.     </form>
  65.  
  66.     </body>
  67.  
  68. </html>
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