/    Sign up×
Community /Pin to ProfileBookmark

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:PHPlearnAssignment3index.php on line 68

( ! ) Notice: Undefined index: in D:PHPlearnAssignment3index.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);
}

?>

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@simplypixieFeb 14.2013 — Firslty, when accessing post variables, you do not use $ in the variable name

[code=php]$_POST["$register"][/code]
Should be
[code=php]$_POST["register"][/code]

I would also change your if statement to this

[code=php]if(isset($_POST['register']) && !empty($_POST['register']) { [/code]

I don't know what your second error means as it doesn't give the name of the undefined index.
Copy linkTweet thisAlerts:
@DerokorianFeb 14.2013 — 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.
×

Success!

Help @zack_lee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...