Guest User

Untitled

a guest
Feb 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_POST['submitted'])) {
  4.  
  5.     include('connect-mysql.php');
  6.  
  7.     $username = $_POST['username'];
  8.     $sqlinsert = "INSERT INTO data (username) VALUES ('$username')";
  9.     $row = mysql_fetch_assoc($obj1);
  10.  
  11.     if(mysql_num_rows($obj1) > 0){ //name exists
  12.     }else{ //Name doesn't exist
  13.    
  14.     if (!mysqli_query($dbcon, $sqlinsert)) {
  15.         die('error inserting new record');
  16.     } //end of nested if statement
  17.     }
  18.     $newrecord = "1 record added to the database";
  19.  
  20. } //end of main if statement
  21.  
  22. ?>
  23.  
  24. <html>
  25. <head>
  26. <title>Youtube Statistics</title>
  27. </head>
  28. <body>
  29.  
  30. <h1>Submit user</h1>
  31.  
  32. <form method="post" action="insert-data.php">
  33. <input type="hidden" name="submitted" value="true">
  34. <fieldset>
  35.     <label>Username: <input type="text" name="username" /></label>
  36. </fieldset>
  37. <br />
  38. <input type="submit" value="add username">
  39. </form>
  40. <?php
  41. echo $newrecord
  42. ?>
  43.  
  44. </body>
  45. </html>
Add Comment
Please, Sign In to add comment