Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: login page

  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    login page

    PHP Code:
    <p>Sign In</p>

    <form action ="form.php" method="post">
         
       <h2>Members Login</h2>
       <br/>
       Please sign in with your username and password.
       <br/>
        email <INPUT type="text" name="email" value="" id="email"/> <BR>
        password<INPUT type="password" name="password" value="" id="password"/> <BR>
        <br/>
        <INPUT type="submit" value="Send"> <INPUT type="reset">


    </form>

    this is my php page

    <html>
    <head></head>
    <body>

    <form = "loginUser.php" action= "Get">

    <?php

    // connect to db

    $connection mysql_connect("localhost","root","");
    if(!
    $connection)
    {
    die(
    "database connection falied: "mysql_error());
    }

    // select the database

    $db_select mysql_select_db("admin",$connection);
    if(!
    $db_select){
        die(
    "Database connection falied "mysql_error());
    }


    $username $_POST['username'];
    $password $_POST['password'];
    $email $_POST['email'];



    // query the database

    $qvar "INSERT INTO login(
            email,username,password
          ) VALUES (
                '{$email}','{$username}','{$password}'
                )"
    ;



    $queryDB mysql_query($qvar,$connection);

    // returned data


    if(!$queryDB)
    {
        die(
    "Database query failed: " mysql_error());
    }
    else{
        echo 
    "Thank you for registering your username <b>"$username"</b> <br/>your shopping account has been created!<br/>";
        
        echo 
    "<a href='loginUser.php'>Click here to Login</a>";
    }


    ?>

    </form>
    <body>
    </html>
    and this is the message im gettiing
    Notice: Undefined index: username in G:\webclient\xampp\htdocs\Mywebsite\form.php on line 25
    Database query failed: Duplicate entry '' for key 'PRIMARY'

    where am i going wrong?
    Last edited by Inigoesdr; 05-18-2011 at 05:29 AM.

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    which is line 25?

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Your form is incorrect, it should be:
    Code:
    <form action="loginUser.php" method="post">
    Also, you are getting that error because you are trying to access a key in an array($_POST in this case), when the key hasn't been defined. You need to at least check to see if the form has been posted with something like
    PHP Code:
    if(!empty($_POST))
    {
        
    // your login code

    Also, be sure to escape user input. Check the stickies for more information.

  • #4
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thank you

    thank you, it work

  • #5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •