[HELP]Registration page refuses to insert INFO. L2J 

Joined
May 12, 2005
Messages
251
Reaction score
9
Okay, so i decided to make a own little nice CMS wiz basic shit. Downloaded a webpack since i couldn't be arsed to write all from scratch. Now this registration script i have it refuses to insert info into the database (no errors) However it does tell me that the account is created, and it does tell me that an account already exist if i choose an account name that DOES really exist so IS connected somehow but just refused to insert new account info.

Infos:
Table structure:
login - password - accessLevel - blah blah blah blah

PHP CODE: The whole .php page.
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/JavaScript">

(NVM THIS THINGY LINK INCLUDE HERE)
include("XXXXXXXX/XXXXXXXX/XXXXXXXX/config_.php");

function isAlphaNumeric(value)
{
  if (value.match(/^[a-zA-Z0-9]+$/))
    return true;
  else
    return false;
}
function checkform(f)
{
  if (f.account.value=="")
  {
    alert("Error: You forgot to type in your desired Login name.");
    return false;
  }
  if (!isAlphaNumeric(f.account.value))
  {
    alert("Error code: Illegal characters detected in your Login name!");
    return false;
  }
  if (f.password.value=="")
  {
    alert("Error: You forgot to type in your desired password.");
    return false;
  }
  if (!isAlphaNumeric(f.password.value))
  {
    alert("Error code: Illegal characters detected in your password!");
    return false;
  }
  if (f.password2.value=="")
  {
    alert("Error code: 5");
    return false;
  }
  if (f.password.value!=f.password2.value)
  {
    alert("Error: Passwords doesn't match.");
    return false; 
  }
  return true;
}
</script>
</head>

<form method="post" action="" onsubmit="return checkform(this)">
  <div align="center">
    <table width="100%" class="reg">
      <tr>
        <td width="19%"> </td>
        <td width="31%"><strong>Login</strong></td>
    <td width="50%">
      <input type="text" name="account" id="user" maxlength="15"/></td>
   </tr>
      <tr>
        <td> </td>
        <td><strong>Password</strong></td>
    <td>
      <input type="password" name="password" id="pass" maxlength="15"/></td>
   </tr>
      <tr>
        <td> </td>
        <td><strong>Repeat Password</strong></td>
    <td>
      <input type="password" name="password2" id="pass" maxlength="15" /></td>
   </tr>
      <tr>
        <td colspan="3" align="center">
          <br />
          <input type="submit" name="submit" id="botao" value="Create Account" />        </td>
   </tr>
    </table>
  </div>
</form>
<?php
if(ereg("^([a-zA-Z0-9_-])*$", $_POST['account']) && ereg("^([a-zA-Z0-9_-])*$", $_POST['password']) && ereg("^([a-zA-Z0-9_-])*$", $_POST['password2']))
{
	if ($page="index.php" && $_POST['account'] && strlen($_POST['account'])<16 && strlen($_POST['account'])>3 && $_POST['password'] && $_POST['password2'] && $_POST['password']==$_POST['password2'])
	{	
		$check=mysql_query("select * from accounts where login='".$_POST['account']."'");
		$check1=mysql_num_rows($check);
		if($check1>0)
		{
			echo '<center><p><b><font color="red">Account name taken!</font></p></b></center>';
		}
		else
		{
	  		mysql_query("INSERT INTO accounts (login, password, accessLevel) VALUES ('".$_POST['account']."', '".base64_encode(pack('H*', sha1($_POST['password'])))."', 0)", $link);
  			mysql_close($link);
	 		print '<center><p><b><font color="#0066FF">Account Created!</font></b></p></center>';
		}
	}
	else
	{
  	print '<p><b> </b></p>'.mysql_error();
	}
}
else
{
	echo "Unknown Error/Undefined Error - Contact Web Admin. ";
}
?></p></div>
</body></html>
 
Last edited:
your script is quite messed up
I've noticed that you try to:
Code:
include("XXXXXXXX/XXXXXXXX/XXXXXXXX/config_.php");
and it's a PHP code, so you must wrap it up in <?php ?> tags
next...
it's bad practice if you close the connection somewhere in the middle of the code...
best place to disconnect from the connection is after the </html> tag, but it's your choise.
the last thing:
where do you connect to your database? at that config file or somewhere else?
 
Upvote 0
well I suggest you not to mix Javascript and PHP if you are a beginner...
it would be easier to add things without worrying to mess something up...
btw: don't put the include function in javascript code... put it before the <html> tag.
 
Upvote 0
Back