[PHP] Driving me CRAZY!!!
O.K. here's the deal...I've got a .php file called register.php(registration script) and i have spent 2 hours trying to correct the error:
"faultCode0faultStringParse error:syntax error, unexpected '`', expecting ')' in /home/vol2/warezhostz.info/wz_993675/kzone.warezhostz.info/htdocs/register.php on line 19".
There is no '`' or ` anymore on line 19 but it keeps giving me that error. Could someone please tell me whats wrong and what needs to be corrected? (I dont know much about PHP, but im pretty sure im not blind)
So, anyway, here is the register.php, and please(if possible), tell me what the mistake is that i made...
PHP Code:
<html>
<?php include("includes/head.php"); ?>
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/db_connect.php');
if($_SESSION['logged_in'] == 1)
{
//REDIRECT TO HOMEPAGE
header('Location: http://' . $_SERVER['HTTP_HOST'] . '');
} else {
if(isset($HTTP_POST_VARS['submit']))
{
//BEGIN CHECKING USERNAME...
if(!$_POST['username']) die('Alert: username field was blank.');
//array of invalid characters
$junk = array('.' , ',' , '/' , '\' , ';' , '*', '&', '^', '%', '$', '#', '@', '!', '~', '+',
'(', ')', '|', '{', '}', '<', '>', '?', ':', '"', '=');
//starting lenght of username
$len = strlen($_POST['username']);
//replace invalid characters
$_POST['username'] = str_replace($junk, '', $_POST['username']);
$test = $_POST['username'];
//if lenghts are different ($len smaller), invalid characters found, so prompt error.
if(strlen($test) != $len) {
die('Username Error: Username contained invalid characters. You can only use A-Z, 0-9 and
the
underscore (_).');
}
//Check if username already exists...
$q2 = mysql_query("SELECT * FROM `members` WHERE `username` = '".$_POST['username']."'");
$q3 = mysql_fetch_object($q2);
if($q3->username == $_POST['username']) {
die('<BR><BR>Sorry, but the username "'.$q3->username.'" is taken, please choose
another.');
}
if(!$_POST['password']) {
die('Error: Password field was blank');
}
if(!$_POST['verify_password']) {
die('Error: Verify Password field was blank.');
}
if($_POST['password'] != $_POST['verify_password']) {
die('Error: The passwords do not match.');
}
if(strlen($_POST['password']) < 6 ) {
die('Error: Your password is too short. Must be 6 or more characters in length.');
}
$insert ="INSERT INTO `members` (username, user_password, user_email) VALUES
('".$_POST['username']."',
'".md5($_POST['password'])."', '".$_POST['email']."')";
$insert2 = mysql_query($insert);
if(!$insert2) die(mysql_error());
echo('Registration Successful, Welcome new member! You can now login to your new account.');
} else {
?>
<body>
<div id="wrapper">
<div style="position: absolute; top:-8%;">
<img src="images/bshelf.png" alt="" title="" />
</div>
<div class="topt">
<img src="images/woxhead.jpg" alt="" title="" />
</div>
<div id="content">
<!-- Start left-right blocks loop -->
<?php include("includes/sitenews.php"); ?>
<?php include("includes/sitemenu.php"); ?>
<?php include("includes/linksnaffils.php"); ?>
<!-- End left-right blocks loop -->
</div>
<div id="centercontent">
<div class="centerc">
<div class="blockTitlerl">Some wide block</div>
<div class="blockContentc">
<table>
<form name="signup" action="<? $_SERVER['PHP_SELF']; ?>" method="POST">
<tr>
<td>Username: <BR> (only A-Z, 0-9 and _ Allowed)<BR></td>
<td><input type="text" id ="username" name="username" value="" maxlength="30"> <BR></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" id="password" name="password" value="" maxlength="30"><BR>
(minimum 6
characters)</td>
</tr>
<tr>
<td>Verify Pass:</td>
<td><input type="password" id="verify_password" name="verify_password" value=""
maxlength="30"><BR>
</td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" id="email" name="email" value="" size="30"><br></td>
</tr>
<tr>
<td>Click to Complete Signup:</td>
<td><input type="submit" id="submit" name="submit" value="submit"></td>
</tr>
</form>
</table>
<?
} //end not logged in
} //end submit not pressed
?>
</div>
</div>
<?php include("includes/footer.php"); ?>
</body>
</html>
Re: [PHP] Driving me CRAZY!!!
PHP Code:
$junk = array('.' , ',' , '/' , '\' , ';' , '*', '&', '^', '%', '$', '#', '@', '!', '~', '+',
Just luving the php tags,
Were the orange begins, the code dies
Re: [PHP] Driving me CRAZY!!!
Ow thank you, i've been trying to fix this for over 2 hours now...<3 forever.
Re: [PHP] Driving me CRAZY!!!
if you want a parse the usernames why not use a function with some regex :D here ill leave you the function
PHP Code:
function isValidUser($user) {
$pattern = "^[_a-zA-Z0-9-]{4,10}$";
if (eregi($pattern, $user)){
return true;
}
return false;
}
simple to use:
PHP Code:
if (!isValidUser($_POST['username'])) { die('some error msg'); }
i know this isnt a problem for you, but maybe will be usefull.