Jump to content


Photo

registration help please urgent


  • Please log in to reply
2 replies to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 25 August 2006 - 04:18 AM

i have a problem with my registration
i just want it to write 2 more items to the database

"name and email"

<?
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>

<?
}
?>
:o

#2 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 25 August 2006 - 05:20 AM

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?
What is the CoronaMatrix?

#3 jvalarta

jvalarta
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 25 August 2006 - 05:31 AM

INSERT INTO users (username,password,name,email) VALUES ('$username', '$password','$name','$email')




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users