-1

(I have some problems when i insert into the form the user&email&password it wasn't added to database I wanna the value which i add to this registration form to appear in the database on php my admin there's my code i don't know what the wrong about it

require "connect.php";
echo "<br>";

if(!empty($_POST))
{
    if(isset($_POST['user'],$_POST['email'],$_POST['pass']))
    {
        $user=mysql_real_escape_string($_POST['user']);
        $email=mysql_real_escape_string($_POST['email']);
         $pass=md5(mysql_real_escape_string($_POST['pass']));
             if(!empty($user)&&!empty($email)&&!empty($pass))
        {


          $sql=mysql_query("INSERT INTO user(username,email,password) VALUES('$user','$email','$pass')");
                }
            }
          }
          ?>
<html>
<head><title>sign up</title></head>
<body>
    <form method="post">
        <table>
            <tr>
                <td><input type="text" name="user" placeholder="username">Username</td><br><br>

            </tr>
            <tr>
                <td><input type="text" name="email" placeholder="E_mail">email</td><br><br>

            </tr>
            <tr>
                <td><input type="password" name="pass" placeholder="password">password</td><br><br>

            </tr>
            <tr>
                <td><input type="submit" name="sub" value="sign up"></td>

            </tr>
        </table>
    </form>
</body>
</html>

my connect.php page

<?php
$connect=new mysqli ('localhost','eman','password','registration');
if($connect->connect_errno)
{
    die("connect error :".$connect->connect_errno);
}
else
{
    echo "connected successfully";
}

tablename in my data base :user database name :registration fields :id/username/email/password

emma
  • 11
  • 3

1 Answers1

0

Your connect.php is defining a mysqli connection $connect which is never used in the other page. Further, you're using mysql_* functions on the other page instead of the mysqli_* functions one would expect to use with $connect.

miken32
  • 42,008
  • 16
  • 111
  • 154