Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //config.php
- <?php
- $db_host="localhost";
- $db_user="root";
- $db_pass="";
- $db_name="enr";
- $db = new mysqli($db_host, $db_user, $db_pass, $db_name);
- if($db->connect_error){
- die("Connection failed: " . $db->connect_error);
- }
- ?>
- //update.php
- <!DOCTYPE html>
- <html>
- <head>
- <title>Update</title>
- </head>
- <body>
- <?php
- include ("config.php");
- $id = "";
- $image = "";
- $name = "";
- $reg ="";
- $contact = "";
- $email = "";
- $shift = "";
- $semester = "";
- $courses = "";
- if (isset($_POST["update"]))
- {
- $query = "UPDATE students SET image = '$image', name = '$name', reg = '$reg', contact = '$contact', email = '$email', shift = '$shift',semester ='$semester', courses = '$courses' WHERE id = '$id' ";
- try{
- $data = mysqli_query($db, $query);
- if($data)
- {
- if(mysqli_affected_rows($db) > 0)
- {
- echo '<div id="msg"> Data Updated <a href="view.php">Check Data</a> </div>';
- }else{
- echo '<div id="msg"> Data could not be updated <a href="view.php">Check Data</a> </div>';
- }
- }
- } catch (Exception $ex) {
- echo 'Error Update '.$ex->getMessage();
- }
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment