0

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>

Edited by guggilosmodz: n/a

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by lyrico
0

Hey, assuming your id field is a.increment -

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

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>

Edited by lyrico: n/a

0

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?

0

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>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.