Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "Stu445";
- $password = "Stu4998!";
- $dbname = "stu445";
- $conn = new mysqli($servername,$username,$password,$dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $Name = $_POST["Name"];
- $Description = $_POST["Description"];
- $Date = date("Y/m/d");
- if ($Name != ""){
- $sql = "INSERT INTO comments (Date, Name, Comments) VALUES ('$Date', '$Name', '$Description')";
- }
- if ($_POST['submit']) {
- if (empty($_POST['Name'])){
- die('"Name" cannot be empty');
- }
- if (empty($_POST['Description'])){
- die('"Description" cannot be empty');
- }
- }
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- }
- else {
- // Failed
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement