View Single Post
  #8  
Old 04-02-2009, 10:39 AM
Tequila's Avatar
Tequila Tequila is offline
The Grim One
 
Join Date: Jan 2009
Location: Souther Tier, New York State
Posts: 1,356
Gender: Female
Credits: 125,308
Tequila is on a distinguished road
Default RE: Integrate script with php safe includes?

New development, working on editing register2.php
Code:
Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in /home/enddayne/public_html/beta/register2.php on line 19
PHP Code:
<?
//Protect the database
$username preg_replace("/[^a-zA-Z0-9\\040.]/"""$username);
$pass1 preg_replace("/[^a-zA-Z0-9s]/"""$pass1);
$pass2 preg_replace("/[^a-zA-Z0-9s]/"""$pass2);
$email preg_replace("/[^a-zA-Z0-9@._-]/"""$email);
$tos preg_replace("/[^a-zA-Z0-9s]/"""$tos);

// Connect to our database

$conn mysql_connect($dbhost$dbuser$dbpass) or die ('Error connecting to mysql database!');
mysql_select_db($dbname);

//Check for errors...
if($username == "" or $pass1 == "" or $pass2 == "" or $email == ""){

echo(
"A required form element was left blank.  Please <a href='register.php'>go back</a> and fill out all the form elements and try again.")

if(
$tos != 'tosyes'){
echo 
"You did not agree to the Terms of Service.  You must agree to the TOS to use this site."

}

if(
$pass1 != $pass2){
echo 
"Your passwords do not match.  Please <a href="register.php">go back</a> and correct this issue."

die();
}

//Check that username does not already exist

$query "SELECT * FROM users WHERE username = '$username'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {

$luser=@mysql_result($result,$i,"username");


$i++;
}

$luser strtolower($luser);
$u2 $str strtolower($username);

if(
$luser == $u2){
echo 
"Your username has been taken.  Please <a href="register.php">go back</a> and select a different username."

die();
}

//All checks pass, create the user
$pass1 md5($pass1); //MD5 the password
mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free','0')"); 

echo 
"Your account has been created with the username '.$username.'.  <a href="login.php">Click here to log in to your account.</a>"


?>