All pastes #73913 Raw Edit

Qube

public text v1 · immutable
#73913 ·published 2006-06-28 13:02 UTC
rendered paste body
<html>
<head>
    <title>gel dealear: feedback</title>
</head>

<body>
  <h2>Feedback</h2>
  <br>
<?
  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $user     = isset($_POST['user'])     ? $_POST['user'] : '';
    $email    = isset($_POST['email'])    ? $_POST['email'] : '';
    $comments = isset($_POST['comments']) ? $_POST['comments'] : '';
    $spam     = isset($_POST['spam'])     ? $_POST[' '] : '';
    if (empty($user) || empty($email) || empty($comments) || empty($spam)) {
      echo EOVALIDATION
		<H2>Whoops!</h2>
		<BR>
		Please fill in all fields.
		<BR>
		<A HREF="feedback.html">Click here to go bac to the feedback page.</A>
EOVALIDATION;
    } else { # all is good

      $db = mysql_connect("localhost");
      if (mysql_errno()) die mysql_error();
      mysql_select_db("sample", $db);
      if (mysql_errno()) die mysql_error();
      $addfeedback = sprintf("INSERT INTO feedback (user, email, spam, comments)
		VALUES ('%s','%s', '%s','%s')",
           mysql_real_escape_string($user),
           mysql_real_escape_string($email),
           mysql_real_escape_string($spam),
           mysql_real_escape_string($comments));
;
      $result = mysql_query($addfeedback) or die("Cannot query the database.<br>" . mysql_error());
      echo <<<EOSUCCESS
        We have added your comments to our database.<BR><BR>
        <A HREF="feedback.html">Click here to go back to the feedback page.</A>
</body>
</html>
EOSUCCESS;
    }
  } else { # this is a GET request - do something here
  }
}