Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Test DB PHP Script</title>
- </head>
- <body>
- <?php
- //use PHP to connect MySQL
- echo "I hate pawdhp";
- $host = 'localhost';
- $user = 'zarycki2_g';
- $password = "CM12p0p";
- $dbconn = mysql_connect($host, $user, $password) or die ('Could not connect to
- database: ' . mysql_error());
- mysql_select_db('zarycki2_CaffeinateMe');
- //get variables from POST
- $author = $_POST['author'];
- $date = $_POST['date'];
- $rating = $_POST['rating'];
- $comments = $_POST['comments'];
- //Find the Highest ID to get the next ID
- $query = "SELECT MAX(Review_ID) from Review";
- $result = mysql_query($query);
- if (!$result) {
- die('invalid query: ' . mysql_error());
- }
- $row = mysql_fetch_array($result);
- $number = $row['MAX(Review_ID)'] + 1;
- echo $number ;
- $query = "INSERT INTO Review(Review_ID, Author, Date, Rating, Comments) VALUES('$number','$author','$date','$rating','$comments')";
- $result = mysql_query($query);
- if (!$result) {
- die('Invalid query: ' . mysql_error());
- }
- echo "lol";
- mysql_close($dbconn);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement