www.webdeveloper.com
Results 1 to 3 of 3

Thread: Php problem

  1. #1
    Join Date
    Feb 2013
    Posts
    1

    Php problem

    Hi ,I got a problem , I try to input the username and password into database,but I got those problem


    ( ! ) Notice: Undefined variable: register in D:\PHPlearn\Assignment3\index.php on line 68

    ( ! ) Notice: Undefined index: in D:\PHPlearn\Assignment3\index.php on line 68


    <input type="submit" name="login" value="Login">
    <input type="submit" name="register" value="register">
    <?php


    if($_POST["$register"]!="")
    {

    mysql_select_db("assignment3" , $connect);
    mysql_query("INSERT INTO ass3_info (name,password)
    VALUES ('".$username."','".$pwd."')");

    mysql_close($connect);
    }

    ?>

  2. #2
    Join Date
    Aug 2012
    Posts
    155
    Firslty, when accessing post variables, you do not use $ in the variable name

    PHP Code:
    $_POST["$register"
    Should be
    PHP Code:
    $_POST["register"
    I would also change your if statement to this

    PHP Code:
    if(isset($_POST['register']) && !empty($_POST['register']) { 
    I don't know what your second error means as it doesn't give the name of the undefined index.

  3. #3
    Join Date
    Oct 2010
    Location
    Ohio
    Posts
    233
    The second error is caused by the first. PHP doesn't find a definition for a $register variable, so it gives an error and evaluates it to NULL. It then tries to evaluate $_POST[NULL] and throws the second error.
    ~Ryan
    www.rdennispallas.com <-- Personal Site, changing regularly cuz its ugly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles