CrazyDiamond

PHP skripts atbildes uz kontroljautājumu rediģēšanai

Jun 16th, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2.  
  3. //header('Location: Quastions2.php');
  4.     include'inc.db.Answers.php';
  5.     $conn = mysqli_connect($hostname, $username, $password, $dbname);
  6.     mysqli_set_charset( $link, "utf8" );
  7. // Check connection
  8.  
  9. if (!$conn) {
  10.       die("Connection failed: " . mysqli_connect_error());
  11. }
  12.  
  13.  if(isset($_POST['submitComment'])){
  14.     $qid = $_POST['qid'];
  15.     //$date = $_POST['date'];
  16.     //$client = $_POST['client'];
  17.     $text = $_POST['text'];
  18.    // $report = $_POST['Report'];
  19.     $sql = "INSERT INTO Answers (qid, date, client, text)
  20.      VALUES ('$qid', CURRENT_TIMESTAMP, '{$_SERVER['REMOTE_ADDR']}', '$text')";
  21.     if (mysqli_query($conn, $sql)) {
  22.           echo "New record created successfully";
  23.     } else {
  24.           echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  25.     }
  26. }
  27. mysqli_close($conn);
  28. header("Location: Questions.php");
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment