<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>login form</title> </head> <body> <h3>form</h3> <form class="" action="connect.php" method="POST"> <label for="firstname">enter name</label> <input type="text" name="firstname" value="" placeholder="enter first name" required> <br><br> <label for="lastname">last name</label> <input type="text" name="lastname" value="" placeholder="enter last name" required> <br><br> <label for="email">email</label> <input type="email" name="email" value="" placeholder="enter email" required> <br><br> <label for="password">password</label> <input type="password" name="password" value="" placeholder="enter password" required> <br><br> <label for="cpassword">confirm password</label> <input type="password" name="cpassword" value="" placeholder="enter confirm password" required> <br><br> <input type="submit" name="save" value="submit"> </form> </body> </html>
<?php $servername="localhost"; $username="root"; $password=""; $dbname="demo"; $conn=mysqli_connect($servername,$username,$password,$dbname) or die("connection failed"); if(isset($_POST['save'])){ $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $email=$_POST['email']; $password=$_POST['password']; $cpassword=$_POST['cpassword']; $sql="INSERT INTO `users` (`First Name`, `Last Name`, `Email`, `Password`, `Confirm Password`) VALUES ('$firstname', '$lastname', '$email', '$password', '$cpassword')"; $sqlres=mysqli_query($conn,$sql); if($sqlres){ echo "data inserted successfully"; } else { echo "data is not inserted"; } } ?>
I create a simple form and saving its data into database besides it saving data it show my php file on browser
it show my php file on browser
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)