Guest User

Untitled

a guest
Oct 23rd, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. php1.php
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <?php include('testing.php'); ?>
  5. <body>
  6. <div class="panel-body">
  7. <form action="testing.php" method="post">
  8. <div class="form-group">
  9. <label for="name">Name:</label>
  10. <input type="text" class="form-control" id="txtname">
  11. </div>
  12. <div class="form-group">
  13. <label for="age">Age:</label>
  14. <input type="text" class="form-control" id="txtage">
  15. </div>
  16. <button type="submit" class="btn btn-default" onclick="insertq();">Submit</button>
  17. </form>
  18. </div>
  19. </div>
  20. </div>
  21.  
  22. </body>
  23. </html>
  24.  
  25. php2.php
  26. <?php
  27. $servername = "localhost";
  28. $username = "root";
  29. $password = "";
  30. $db = "testing";
  31.  
  32. // Create connection
  33. function dbcon(){
  34. $conn = new mysqli($servername, $username, $password, $db);
  35.  
  36. // Check connection
  37. if ($conn->connect_error) {
  38. die("Connection failed: " . $conn->connect_error);
  39. }
  40. echo "Connected successfully";
  41. }
  42. function insertf(){
  43. echo "adfasdfasdf";
  44. $sql = "INSERT INTO info (name, age)
  45. VALUES (//txtname, //txtage)";
  46.  
  47. if ($conn->query($sql) === TRUE) {
  48. echo "New record created successfully";
  49. } else {
  50. echo "Error: " . $sql . "<br>" . $conn->error;
  51. }
  52.  
  53. $conn->close();
  54.  
  55. }
  56. ?>
Add Comment
Please, Sign In to add comment