Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <title> Music Artist Form</title>
- </head>
- <body>
- <form id="form" name ="form" method="post" action="DBWrite.php">
- <label>Artist Name -
- <input type="text" name="artistname" id="artistname"><br>
- </label>
- <label>Short Bio -
- <input type="text" name="shortbio" id="shortbio"><br>
- </label>
- <label>Years Active -
- <input type="int" name="yearsactive" id="yearsactive"><br>
- </label>
- <label>Genre -
- <input type="text" name="genre" id="genre"><br>
- </label>
- <label>Top Album -
- <input type ="text" name="topalbum" id="topalbum"><br>
- <input type="submit" name="submit" value="Submit"><br><br>
- </form>
- <?php
- //Login details
- $servername = "lochnagar.abertay.ac.uk";
- $username = "sql1500457";
- $password = "D7rS&#jV5rYO";
- $dbname = "sql1500457";
- //Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- //Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error()) . "<br>";
- }
- echo "Connected Successfully" . "<br>";
- $sql = "SELECT artistname, shortbio, yearsactive type FROM musicThree";
- $result=mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0){
- while($row = mysqli_fetch_assoc($result)){
- 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>";
- }
- } else {
- echo "0 results";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement