Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['submitted'])) {
- include('connect-mysql.php');
- $username = $_POST['username'];
- $sqlinsert = "INSERT INTO data (username) VALUES ('$username')";
- $row = mysql_fetch_assoc($obj1);
- if(mysql_num_rows($obj1) > 0){ //name exists
- }else{ //Name doesn't exist
- if (!mysqli_query($dbcon, $sqlinsert)) {
- die('error inserting new record');
- } //end of nested if statement
- }
- $newrecord = "1 record added to the database";
- } //end of main if statement
- ?>
- <html>
- <head>
- <title>Youtube Statistics</title>
- </head>
- <body>
- <h1>Submit user</h1>
- <form method="post" action="insert-data.php">
- <input type="hidden" name="submitted" value="true">
- <fieldset>
- <label>Username: <input type="text" name="username" /></label>
- </fieldset>
- <br />
- <input type="submit" value="add username">
- </form>
- <?php
- echo $newrecord
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment