Kev0121 Posted January 9, 2009 Share Posted January 9, 2009 Well, basically trying to create just a simple register script but getting errors.. 1) Its been inserted into the database but its shown as blank and cant see the name or password 2) I get these errors.. Notice: Undefined index: username in C:\wamp\www\PHPDesk\testreg.php on line 31 Notice: Undefined index: password in C:\wamp\www\PHPDesk\testreg.php on line 32 Notice: Undefined variable: user in C:\wamp\www\PHPDesk\testreg.php on line 34 Notice: Undefined variable: user in C:\wamp\www\PHPDesk\testreg.php on line 36 Successfully Registered The Username '..'. Heres my code <?php include "functions.php"; $c = mysql_connect('localhost', 'root', '') or die("Error Connecting To Host." . mysql_error()); $db = mysql_select_db('website') or die("Error Selecting Database." . mysql_error()); if(!isset($_POST['submit'])) { ?> <link rel="stylesheet" type="text/css" href="style.css" /> <form action="" method="post" name="login"> <fieldset id="login"> <legend>Register</legend> Username<br /> <input type="text" name="uname" id="name" maxlength="15" size="20" /><br /> Password<br /> <input type="password" name="pass" id="password" /> <br /> <input type="submit" name="submit" value="Register" /> </fieldset> <?php } else { { $users = protect($_POST['username']); $pass = protect($_POST['password']); $sql = "INSERT INTO `users` (username, password) VALUES ('$user', '$pass')"; $res = mysql_query($sql); echo "Successfully Registered The Username '.$user.'."; } } ?> Link to comment https://forums.phpfreaks.com/topic/140225-simple-reg-script/ Share on other sites More sharing options...
ratcateme Posted January 10, 2009 Share Posted January 10, 2009 $users = protect($_POST['username']); $pass = protect($_POST['password']); should be $users = protect($_POST['uname']); $pass = protect($_POST['pass']); Notice: Undefined index: means the array index you ahve specified does not exists so in this case there is no "username" or "password" index in the $_POST array Scott. Link to comment https://forums.phpfreaks.com/topic/140225-simple-reg-script/#findComment-733759 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.