SHARE
TWEET

Untitled

a guest Mar 20th, 2016 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2.     <html>
  3.     <head>
  4.     <title>Name</title>
  5.     </head>
  6.     <body>
  7.  
  8. <div id="main">
  9. <h1>login details</h1>
  10. <div id="name">
  11. <h2>Name</h2>
  12. <hr/>
  13.  
  14.  
  15. <Form Name ="form1" Method ="POST" ACTION = "name.php">
  16.  
  17. <label>Name: </label>
  18. <input type="text" name="per_name" id="name" required="required" placeholder="please enter name"/><br/><br />
  19.  
  20. <label>Age: </label>
  21. <input type="text" name="per_age" id="age" required="required" placeholder="please enter age"/><br/><br />
  22.  
  23.  
  24.  
  25. <input type="submit" value=" Submit " name="submit"/><br />
  26.  
  27. </form>
  28. </div>
  29. <!-- Right side div -->
  30.  
  31. </div>
  32.  
  33. </div>
  34.  
  35. </body>
  36. </html>
  37.    
  38. <?php
  39. if(isset($_POST["submit"])){
  40. $servername = "localhost";
  41. $username = "root";
  42. $password = "pass";
  43. $dbname = "details";
  44.  
  45. $connection = new mysqli($servername, $username, $password, $dbname);
  46.  
  47.  
  48. if ($connection->connect_error) {
  49. die("Connection failed: " . $connection->connect_error);
  50. }
  51.  
  52. $sql = "INSERT INTO persons (person_name, person_age)
  53. VALUES ('".$_POST["per_name"]."','".$_POST["per_age"]."')";
  54.  
  55. if ($connection->query($sql) === TRUE) {
  56. echo "person added";
  57. } else {
  58. echo "person not added";
  59. }
  60.  
  61. $connection->close();
  62. }
  63. ?>
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