Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <body>
- <form action="index.php" method="post">
- FirstName:<input type="text" name="fir"><br>
- LastName:<input type="text" name="las"><br>
- E-mail:<input type="text" name="email_l"><br>
- <input type="submit" name="save">
- <input type="submit" name"del_row" value="Delete">
- </form>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = '';
- $dbname = "myDB";
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- else{
- echo "Connected successfully";
- echo "<br>";
- }
- $fir_del = $_POST['fir'];
- if(isset($_POST['save'])){
- $sql = "INSERT INTO tars (firstname, lastname, email) VALUES
- ('".$_POST["fir"]."','".$_POST["las"]."','".$_POST["email_l"]."') ";
- $result = mysqli_query($conn,$sql);
- }
- if(isset($_POST['del_row'])){
- $sql_del = "DELETE FROM tars WHERE firstname=".$fir_del." ";
- $result_del = mysqli_query($conn,$sql_del) or die(mysqli_error());
- }
- mysqli_close($conn);
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment