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);
}
?>
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.
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.
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
Forum Rules
Bookmarks