Advertisement
Guest User

Untitled

a guest
Nov 10th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title> Music Artist Form</title>
  5. </head>
  6. <body>
  7.  
  8. <form id="form" name ="form" method="post" action="DBWrite.php">
  9.  
  10. <label>Artist Name -
  11. <input type="text" name="artistname" id="artistname"><br>
  12. </label>
  13. <label>Short Bio -
  14. <input type="text" name="shortbio" id="shortbio"><br>
  15. </label>
  16. <label>Years Active -
  17. <input type="int" name="yearsactive" id="yearsactive"><br>
  18. </label>
  19. <label>Genre -
  20. <input type="text" name="genre" id="genre"><br>
  21. </label>
  22. <label>Top Album -
  23. <input type ="text" name="topalbum" id="topalbum"><br>
  24.  
  25. <input type="submit" name="submit" value="Submit"><br><br>
  26.  
  27. </form>
  28.  
  29. <?php
  30. //Login details
  31. $servername = "lochnagar.abertay.ac.uk";
  32. $username = "sql1500457";
  33. $password = "D7rS&#jV5rYO";
  34. $dbname = "sql1500457";
  35.  
  36. //Create connection
  37. $conn = mysqli_connect($servername, $username, $password, $dbname);
  38.  
  39. //Check connection
  40. if (!$conn) {
  41. die("Connection failed: " . mysqli_connect_error()) . "<br>";
  42. }
  43. echo "Connected Successfully" . "<br>";
  44.  
  45. $sql = "SELECT artistname, shortbio, yearsactive type FROM musicThree";
  46. $result=mysqli_query($conn, $sql);
  47.  
  48. if (mysqli_num_rows($result) > 0){
  49. while($row = mysqli_fetch_assoc($result)){
  50. echo "<br>" . "Artist name: " . $row["artistname"] . "<br>" . "Short bio: " . $row["shortbio"] . "<br>" . "Years active: " . $row["yearsactive"] . "<br>" . "Genre: " . $row["genre"] . "<br>" . "Top album: " . $row["topalbum"] . "<br>";
  51. }
  52. } else {
  53. echo "0 results";
  54. }
  55.  
  56. ?>
  57.  
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement