perezf Posted August 25, 2006 Share Posted August 25, 2006 i have a problem with my registrationi just want it to write 2 more items to the database"name and email"[code]<?function usernameTaken($username){ global $conn; if(!get_magic_quotes_gpc()){ $username = addslashes($username); } $q = "SELECT username FROM users WHERE username = '$username'"; $result = mysql_query($q,$conn); return (mysql_num_rows($result) > 0);}function addNewUser($username, $password){ global $conn; $q = "INSERT INTO users VALUES ('$username', '$password')"; return mysql_query($q,$conn); mkdir('/'.$username, 0777);}function displayStatus(){ $uname = $_SESSION['reguname']; if($_SESSION['regresult']){?><h1>You are now registered.</h1><p>Thank you <b><? echo $uname; ?></b>, your information has been added to the database, you may now <a href="?page=Login" title="Login">log in</a>.</p><? } else{?><h1>Registration Failed.</h1><p>Sorry, but an error has occurred and your registration for the username <b><? echo $uname; ?></b>, could not be completed.<br>Please try again later.</p><? } unset($_SESSION['reguname']); unset($_SESSION['registered']); unset($_SESSION['regresult']);}if(isset($_SESSION['registered'])){ displayStatus(); return;}if(isset($_POST['subjoin'])){ if(!$_POST['user'] || !$_POST['pass']){ die('You didn\'t fill in a required field.'); } $_POST['user'] = trim($_POST['user']); if(strlen($_POST['user']) > 30){ die("Sorry, the username is longer than 30 characters, please shorten it."); } if(usernameTaken($_POST['user'])){ $use = $_POST['user']; die("Sorry, the username: <strong>$use</strong> is already taken, please pick another one."); } $md5pass = md5($_POST['pass']); $_SESSION['reguname'] = $_POST['user']; $_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass); $_SESSION['registered'] = true; echo "<meta http-equiv=\"Refresh\" content=\"0;url=?page=Register Now\">"; return;}else{?><h1>Register</h1><form action="" method="post"><table align="left" border="0" cellspacing="0" cellpadding="3"><tr><td>Your Name:</td><td><input type="text" name="name" maxlength="30"></td></tr><tr><td>Email Address:</td><td><input type="text" name="email" maxlength="30"></td></tr><tr><td>Username:</td><td><input type="text" name="user" maxlength="30"></td></tr><tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr><tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Register Now"></td></tr></table></form><?}?> [/code]:o Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 25, 2006 Share Posted August 25, 2006 So what's the problem. You don't really state the exact nature of the problem you are having. Are you getting an error on trying to insert your data? Quote Link to comment Share on other sites More sharing options...
jvalarta Posted August 25, 2006 Share Posted August 25, 2006 INSERT INTO users (username,password,name,email) VALUES ('$username', '$password','$name','$email') Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.