Jump to content

Register Script Not Working D:


Ne.OnZ

Recommended Posts

What do you mean, I did define them. Before it goes into the error function, I have this in the code:

 

$query = "INSERT INTO users(username, password, email, rank) VALUES('$username', '$password', '$email', '1')";
$result = mysql_query($query);

 

So they are defined there. And in the check function, I have defined like so:

 

$query = "SELECT `username` FROM `users` WHERE `username` = '$username'";
$result = mysql_query($query) or die("Problem with the query: $query<br />" . mysql_error());

 

So I don't understand you D:

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

ok i added an else if statement to function "check" so that if result equals zero to  do nothing else error.

 

<?php

require("includes/Connect.php");
mysql_select_db("divnx5_web");

$username = $_POST['user'];
$password = sha1($_POST['pass']);
$password2 = sha1($_POST['pass2']);
$email = $_POST['email'];

function error($result, $query)
{
   if(!$result)
   {
      echo "Query Failed: $query<br />" . mysql_errno() . '<br />' . mysql_error();
    }
}

function check($username) 
{ 
      $query = "SELECT `username` FROM `users` WHERE `username` = '$username'";
      $result = mysql_query($query) or die("Problem with the query: $query<br />" . mysql_error());
      
      if (mysql_num_rows($result) > 0)
         echo "The username " . $username . ' is already taken!<br /><br />';
else if (mysql_num_rows($result)==0) 
}



if(!$con)
{
   echo "Registering is disabled right now, please check back later";
}
else
{
  if(!$_POST['register'])
  {
   echo "<br /><br />Use the following form to register a new account with us.
              <form action='register.php' method='post'><br /><br />
              <font size='2'>Username:</font><br />
              <input type='text' id='user' name='user' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br />
<font size='2'>Password:</font><br />
<input type='password' id='pass' name='pass' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br />
<font size='2'>Confirm Password:</font><br />
<input type='password' id='pass2' name='pass2' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br />
<font size='2'>E-mail Address:</font><br />
<input type='text' id='email' name='email' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /><br />
<input type='submit' name='register' id='register' value='Register' style='background-color: #FFFFFF; color: #000000; font-size: 8pt; border: 1 solid #003399' />
<input type='reset' value='Clear' style='background-color: #FFFFFF; color: #000000; font-size: 8pt; border: 1 solid #003399' />
</form>";
  }
  else
  {
     if(!isset($username) || empty($username))
     {
       echo "The username you entered encountered a problem<br />";
       check($username);
     }

     if(!$password || !$password2 || !isset($password) || !isset($password2) || empty($password) || empty($password2))
     {
       echo "The password field(s) cannot be left empty.<br />";
     }

     if(!$email || !isset($email) || empty($email))
     {
       echo "The email you entered encountered a problem<br />";
     }

     if($password != $password2)
     {
        echo "The passwords you entered do not match<br />";
     }
     else
     {
        if(isset($username) || $password == $password2|| isset($email) || !empty($email) || !empty($username)||check($username))
        {
           
               $query = "INSERT INTO users(username, password, email, rank) VALUES('$username', '$password', '$email', '1')";
               $result2 = mysql_query($query);
               error($result, $query);
               mysql_close($con);
               echo "Thank You for registering with us " . $username . '! Before you can login and start using the features of the site, please check the email you provided (' . $email . ') for a confirmation link.';
           
        }
     }
   }
}


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • 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.