Advertisement
RyanSweigert

Number Counter

Mar 30th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4.     <title>Counter</title>
  5.     <link rel="stylesheet" src="css/style.css">
  6. </head>
  7. <body>
  8.     <output id="output">
  9.  
  10.  
  11.     </output>
  12.     <div id="">
  13.         <form name="form" action="" method="post">
  14.             <input type="text" name="counter_input" id="counter-input">
  15.             <input type="submit" value="Submit" class="submit">
  16.         </form>
  17.         <?php
  18.         if (isset($_POST['counter_input'])) {
  19.             $counter_input = $_POST['counter_input'];
  20.             if (!empty($counter_input)) {
  21.                 $con = mysql_connect('localhost', 'ryan_main', '***************');
  22.                 if (!$con) {
  23.                     die("Not Connected:" . mysql_error());
  24.                 } else {
  25.                     $select_db = mysql_select_db("ryan_counter", $con);
  26.                     if (!select_db) {
  27.                         die("Not Connected:" . mysql_error());
  28.                     } else {
  29.                         mysql_query("INSERT INTO main_table(number) VALUES ('$counter_input')");
  30.                         mysql_close($con);
  31.                         echo 'I think it worked';
  32.                     }
  33.                 }
  34.             } else {
  35.                 echo "You have to enter a number first";
  36.             }
  37.         }
  38.         ?>
  39.     </div>
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement