Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Member #
    33740
    Hi everyone. I'm having a bit of trouble with my registration script. When I go to my action.php file, I get these errors

    Notice: Undefined index: uname1 in C:\xampp\htdocs\series\action.php on line 2

    Notice: Undefined index: pword1 in C:\xampp\htdocs\series\action.php on line 3

    But, When I test my script, Everything works fine.
    I don't understand what's going on.
    These are my two files:

    index.php:

    PHP Code:
    <html>
    <
    body>

    <
    form action="action.php" method="post">
    Username: <input type="text" name="uname1" />

    Password: <input type="password" name="pword1" />
    <
    input type="submit" value="Login" />
    </
    form>

    </
    body>
    </
    html
    action.php:

    PHP Code:
    <?php
    $username_1 
    $_POST['uname1'];
    $password_1 $_POST['pword1'];
    $con mysql_connect("localhost""root""");
    if (!
    $con)
    {
    die(
    'Could not connect: 'mysql_error());
    }

    mysql_select_db("user1"$con);

    mysql_query("INSERT INTO userlogin (username, password)
    VALUES ('
    $username_1', '$password_1')");

    mysql_close($con);
    ?>

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    You're just getting a warning.
    You can suppress PHP warnings if you wish.

    Or, try to correct it by changing this:

    $username_1 = $_POST['uname1'];
    $password_1 = $_POST['pword1'];

    To this:

    if($_POST['uname1']){
    $username_1 = $_POST['uname1'];
    }
    if($_POST['pword1']){
    $password_1 = $_POST['pword1'];
    }

    See if that does anything.
    The error is just saying that you didn't define the variables ahead of time.
    It's possible that the $_POST variables could be empty.


  4. #3
    Junior Member Eddy's Avatar
    Join Date
    Nov 2012
    Posts
    6
    Member #
    33883
    Liked
    1 times
    Well You cant just go to action.php without passing any variable, you have to pass some variable before you go to aaction.php, because when you go to action.php

    $_POST['uname1'];
    $_POST['pword1'];

    they are empty " ", there is nothing inside the post.

    Any questions please ask.

    Regards
    Eddy


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:20 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com