Can you please tell me where i am going wrong i am trying to insert just the username and stuff into my database and its not showing up please help me ASAP! it is connecting to the server okay its just that for some reason its not showing up in the DB!

<?php
echo "<h1>Register</h1>";
$submit = $_POST["submit"];
$usernamenew = strip_tags($_POST["usernamenew"]);
$passwordnew = md5(strip_tags($_POST["passwordnew"]));
$repeatpasswordnew = md5(strip_tags($_POST["repeatpasswordnew"]));
$email = $_POST["email"];
$date = date(Y-m-d);

if ($submit)
{
    //check for existence
    if ($usernamenew&$passwordnew&$repeatpasswordnew&$email)
    {
        if ($passwordnew == $repeatpasswordnew)
        {
            // Open database
            echo "Success!";
            $connect = mysql_connect("localhost","root","");
            if (!$connect)
            {
                die("Could not connect!");
            }
            else
            {
                mysql_select_db("users");
                $sql = "INSERT INTO `users` (`id`, `username`, `password`, `email`, `date`) VALUES (NULL, \'$usernamenew\', \'$passwordnew\', \'$email\', \'$date\');";
                mysql_query("$sql");
            }
        }
        else
        {
            echo "The passwords you entered do not match!";
        }
    }
    else
    {
        echo "Please fill in all the blanks!";
    }
}

?>


<html>
    <form action="register.php" method="POST">
        
        NEW USERNAME:<input type="text" name="usernamenew" maxlength="25" /><br>
        NEW PASSWORD:<input type="password" name="passwordnew" maxlength="25" /><br>
        REPEAT NEW PASSWORD:<input type="password" name="repeatpasswordnew" maxlength="25" /><br>
        EMAIL ADDRESS:<input type="text" name="email" maxlength=64 /><br>
        <input type="submit" name="submit" value="Create Account" />
        
    </form>
</html>

Hey, assuming your id field is a.increment -

$sql = "INSERT INTO `users` (`username`, `password`, `email`, `date`) VALUES ('$usernamenew', '$passwordnew', '$email', '$date')";

Try this code. I modified it.

<?php
echo "<h1>Register</h1>";
$submit = $_POST["submit"];
$usernamenew = strip_tags($_POST["usernamenew"]);
$passwordnew = md5(strip_tags($_POST["passwordnew"]));
$repeatpasswordnew = md5(strip_tags($_POST["repeatpasswordnew"]));
$email = $_POST["email"];
$date = date(Y-m-d);
 
if ($_POST['submit']=="Create Account")
{
    //check for existence
    if ($usernamenew=="" || $passwordnew=="" || $repeatpasswordnew=="" || $email=="")
    {    
        echo "Please fill in all the blanks!";    
    }

    else
      {
           if ($passwordnew == $repeatpasswordnew)
           {
                 // Open database
                 echo "Success!";
                 $connect = mysql_connect("localhost","root","");
                 if (!$connect)
                 {
                      die("Could not connect!");
                 }
                  else
                    {
                         mysql_select_db("users");
                          $sql = "INSERT INTO `users` (username,password,email,date) VALUES ('$usernamenew','$passwordnew','$email','$date')";
                          mysql_query("$sql");
                     }
              }
               else
                 {
                     echo "The passwords you entered do not match!";
                 }
        }   
}
 
?>
 
 
<html>
    <form action="register.php" method="POST">
 
        NEW USERNAME:<input type="text" name="usernamenew" maxlength="25" /><br>
        NEW PASSWORD:<input type="password" name="passwordnew" maxlength="25" /><br>
        REPEAT NEW PASSWORD:<input type="password" name="repeatpasswordnew" maxlength="25" /><br>
        EMAIL ADDRESS:<input type="text" name="email" maxlength=64 /><br>
        <input type="submit" name="submit" value="Create Account" />
 
    </form>
</html>

lyrico i made a copy of that and tried it still nothing is working idk whats wrong? its just not getting put into the db it says success so it is connecting to the database?

ahm ok. so try this code again.

<?php

$connect = Mysql_connect("localhost","root","");
mysql_select_db("name_of_your_db");

echo "<h1>Register</h1>";
$submit = $_POST["submit"];
$usernamenew = strip_tags($_POST["usernamenew"]);
$passwordnew = md5(strip_tags($_POST["passwordnew"]));
$repeatpasswordnew = md5(strip_tags($_POST["repeatpasswordnew"]));
$email = $_POST["email"];
$date = date(Y-m-d);
 
if ($_POST['submit']=="Create Account")
{
    //check for existence
    if ($usernamenew=="" || $passwordnew=="" || $repeatpasswordnew=="" || $email=="")
    {    
        echo "Please fill in all the blanks!";    
    }
 
    else
      {
           if ($passwordnew == $repeatpasswordnew)
           {
              $sql = mysql_query("INSERT INTO users (username,password,email,date) VALUES ('$usernamenew','$passwordnew','$email','$date'");
            }
            
               else
                 {
                     echo "The passwords you entered do not match!";
                 }
        }   
}
 
?>
 
 
<html>
    <form action="register.php" method="POST">
 
        NEW USERNAME:<input type="text" name="usernamenew" maxlength="25" /><br>
        NEW PASSWORD:<input type="password" name="passwordnew" maxlength="25" /><br>
        REPEAT NEW PASSWORD:<input type="password" name="repeatpasswordnew" maxlength="25" /><br>
        EMAIL ADDRESS:<input type="text" name="email" maxlength=64 /><br>
        <input type="submit" name="submit" value="Create Account" />
 
    </form>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.