Jump to content

registration help please urgent


perezf

Recommended Posts

i have a problem with my registration
i 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
Link to comment
https://forums.phpfreaks.com/topic/18613-registration-help-please-urgent/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.