Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername= "localhost";
- $username= "root";
- $password="";
- $dbname="bit2018";
- $msg='';
- $std_id = $_GET['id'];
- //create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- //check connection
- if(!$conn)
- {
- die("Connection failed:" . mysqli_connect_error());
- }
- if(isset($_POST['updatebtn']))
- {
- $std_fname= $_POST['std_fname'];
- $std_lname= $_POST['std_lname'];
- $std_roll= $_POST['std_roll'];
- $std_contact= $_POST['std_contact'];
- $std_address= $_POST['std_address'];
- $sqlQuery = "UPDATE students SET std_fname='$std_fname', std_lname='$std_lname',std_roll='$std_roll',std_contact='$std_contact',std_address='$std_address' WHERE std_id='$std_id';
- if(mysqli_query($conn,$sqlQuery))
- {
- $msg = "Information updated Successfully";
- }
- else
- {
- $msg = "Problem in updating data";
- }
- }
- $selectQuery = "SELECT" FROM students WHERE std_id='$std_id'";
- $result = mysqli_query($conn, $selectQuery);
- $info = mysqli_fetch_assoc($result);
- ?>
- <h1 style = "color:green"><?php echo $msg;?></h1>
- <fieldset>
- <legend>student update form</legend>
- <form method = "POST">
- <b>First Name:</b><input type="text" value="<?php echo $info['std_fname'];?>" name="std_fname" required>
- <hr>
- <b>Last Name:</b><input type="text" value="<?php echo $info['std_lname'];?>" name="std_lname" required>
- <hr>
- <b>Roll:</b><input type="text" value="<?php echo $info['std_roll'];?>" name="std_roll" required>
- <hr>
- <b>Contact:</b><input type="text" value="<?php echo $info['std_contact'];?>" name="std_contact" required>
- <hr>
- <b>Address:</b><input type="text" value="<?php echo $info['std_address'];?>" name="std_address" required>
- <hr>
- <button type="submit" name="updatebtn"> Save</button>
- </form>
- </fieldset>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement