Advertisement
tyler569

Untitled

Dec 9th, 2013
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>DBEntry</title>
  5.         <meta name="description" content="Database entry test">
  6.  
  7.     </head>
  8.  
  9.     <body>
  10.         <!use a table to align stuff and crap>
  11.         <h1>This is my website</h1>
  12.         <b>Login:</b>
  13.         <form name="form1" method="POST" action="">
  14.             <input type="text" name="box1"><br>
  15.             <input type="password" name="box2"><br>
  16.             <input type="submit" value="Go!" name="go1">
  17.         </form>
  18.         <?php
  19.             $con = mysqli_connect("localhost","root","","db");
  20.  
  21.             if (mysqli_connect_errno()) {
  22.                 echo "<p>Failed to connect to server</p>";
  23.             }
  24.  
  25.             if ($_POST) {
  26.                 if ($_POST["box1"]) {
  27.  
  28.                     $ip = $_SERVER["REMOTE_ADDR"];
  29.                     $val = mysql_real_escape_string($_POST["box1"]);
  30.  
  31.                     $sql = "INSERT INTO `db`.`input` (`input_id`, `ip`, `value`)
  32.                         VALUES (NULL, '$ip', '$val')";
  33.  
  34.                     mysqli_query($con, $sql);
  35.                 } else {
  36.                     echo "<p>You need to type something in!</p>";
  37.                 }
  38.             }
  39.         ?>
  40.         <br><br><br>
  41.         <b>Register:</b>
  42.         <form name="form2" method="POST" action="">
  43.             <input type="text" name="box1"><br>
  44.             <input type="password" name="box2"><br>
  45.             <input type="password" name="box2check"><br>
  46.             <input type="submit" value="Go!" name="go1">
  47.         </form>
  48.  
  49.     </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement