Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?php
  2.  
  3. include "createUser.php";
  4.  
  5. ini_set('display_errors', 1);
  6. ini_set('display_startup_errors', 1);
  7. error_reporting(E_ALL);
  8.  
  9. $servername = "localhost";
  10. $username = "webUser";
  11. $password = "davedog";//i think..
  12. $dbName = "webData";
  13.  
  14. $conn = new mysqli($servername, $username, $password, $dbName);
  15.  
  16. if($conn->connect_error){//Error on connection?
  17. die("C0nnection failed: " . $conn->connect_error);//then show the error
  18. }
  19. echo "Connected successfully!";
  20.  
  21. echo <<<HTMLOPEN
  22. <html>
  23. <body>
  24. HTMLOPEN;
  25.  
  26.  
  27.  
  28. echo "<h2>Major Lab</h2><br /><form id='frmMain'><label for='txtUsrName'>Username:</label><input type='text' id='txtUsrName'><br /><label for='txtName'>Name:</label><input type='text' id='txtName'><br /><input type='submit' action='createUser.php'>";
  29.  
  30.  
  31. echo <<<HTMLCLOSE
  32. </body>
  33. </html>
  34. HTMLCLOSE;
  35.  
  36.  
  37.  
  38. $sql = "SELECT id, name, country FROM state WHERE country='Canada';"; //Query String
  39.  
  40. $result = $conn->query($sql);//Execute and store
  41.  
  42. echo "<select id='slctProvinces'>"; //start the select box
  43. while($row = $result->fetch_assoc()){
  44.  
  45. echo "<option value=" . $row["id"] . ">" . $row["name"] . "</option>"; //For each province, add an option
  46.  
  47. }
  48. echo "</select></form>";//End the select box and the form
  49.  
  50. $conn->close(); //Close the connection
  51.  
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement