Jump to content

Recommended Posts

I have just recoded my registration form for my cms to make it look more appealing.

 

But im having a slight problem i get this error

 

Parse error:  parse error, unexpected $ in register.php on line 166

 

and i cant seem to find whats wrong with it. I knows its something small that im just missing.

 

 <?php
/*
iSuS - iScripting.net User System
v2 made by GamingFusion
http://gamingfusion.net
Copyright must stay intact
*/


//If they're already logged in, they don't need to register an account. Redirect them
if ($logged['id']) {

    header("Location: " . $siteurl . "/index.php");

} else {

    // Or else they are a guest, they can register..

    //If the form hasn't been submitted, show it!
    if (!$_POST['submit']) {

        echo '<div>
			<form action="index.php?action=register" method="POST">
<fieldset>
<legend>
User Information
</legend>
<p>Username '.form_input(text,username).'</p>
<p>Password '.form_input(password,password).'
'.form_input(password,cpassword).'</p>
<p>Email '.form_input(text,email).'</p>

</fieldset>
</p>

<p>
<fieldset>
<legend>
Secret Question
</legend>
<p>
<select name="question">
<option value="Select One">Select One</option>
<option value="What was the name of your first pet?">What was the name of your first pet?</option>
<option value="What is your mother maiden name?">What is your mother maiden name?</option>
<option value="What was your first car?">What was your first car?</option>
<option value="What is your favorite band?">What is your favorite band?</option>
<option value="What was the name of your favorite teacher?">What was the name of your favorite teacher?</option>
</select>
</p>
Answer <input type="text" size="25">
</fieldset>
</p>

<p>
<fieldset>
<legend>
Gender
</legend>
<p><input type="radio" name="gender" value="male" /> Male</p>
<p><input type="radio" name="gender" value="female" /> Female</p>
</fieldset>
</p>

<p>'.form_checkbox(terms).''.anchor('index.php?action=viewterms', 'I agree to TOS').'</p>

<p>'.form_button(submit,submit,Register).'</p>

</form>
		  </div> ';
    } else {

        //Or else it has.. Secure all the inputs
        $username = secure($_POST['username']);
        $password = secure($_POST['password']);
        $cpassword = secure($_POST['cpassword']);
        $email = secure($_POST['email']);
	$gender = secure($_POST['gender']);
	$question = secure($_POST['question']);
	$answer = secure($_POST['answer']);
        $terms = secure($_POST['terms']);

        //Get their IP Address
        $ip = secure($_SERVER['REMOTE_ADDR']);

        //And the time they signed up
        $signup = date("d-m-Y");

	//And Set their Avatar
	if ($gender == 'male') {
		$avatar = $siteurl. 'i/avatar_m.png';
	}else{
		$avatar = $siteurl. 'i/avatar_f.png';
	}

        //If anything is empty...
        if (!$username | !$wow | !$password | !$cpassword | !$email | !$terms) {

            echo '<img src="i/warning.png" alt="warning">Please Fill out all fields on the form.';

        } else {

		//if the question and answer are empty...
		if (!$question | !$answer) {

			echo 'PLease Fill out the Secret Question and answer fields.';

		}else{

            //If the passwords dont match
            if ($password != $cpassword) {

                echo 'The passwords do not match';

            } else {

                //If the email they entered wasn't an authentic email..
                if (!isEmail($email)) {

                    echo "Email address invalid";

                } else {
                    //Is the username that they are trying to use already in use?
                    $username_test = mysql_query("SELECT * FROM `users` WHERE username = '$username'");

                    if (mysql_num_rows($username_test) == 1) {

                        echo 'That username is already in use, please select a different one';

                    } else {


                        //Encrypt the password
                        $encpass = sha1($password . SALT);

                        //Insert the user information into the database
                        $add = "INSERT INTO `users` VALUES ('', '$username', '$encpass', '$email', '', '','','', '$ip', '$signup', 'user','', '$gender', '$avatar', '$question', '$answer')";

                        //If the insert went ok...
                        if (mysql_query($add)) {

                            //Tell them their user info
                            echo 'Success, you are now registered<br />';
                            echo 'You can now login using the following information<br /><br />';
                            echo "Username: <strong>$username</strong><br />";
                            echo "Password: <strong>$password</strong><br />";
                            echo "Login <a href='index.php?action=login'>Go</a>";
                        } else {

                            echo 'Error, Registration  not complete. Please contact your administrator.
							  <br />'.mysql_error();

                        }
                    }
                }
            }
        }
    }
}




?>

Link to comment
https://forums.phpfreaks.com/topic/172538-solved-unexpected-error/
Share on other sites

There is no line 166, but from the error it's shown you've added the $ character unescaped somewhere in a string. Note you cannot use..

"$3 is the price"

You have to use:

"\$3 is your price."

 

That is why it says unexpected '$'

 

Yes, you can. If something contains a $-sign, but cannot be interpreted as a variable, PHP will just ignore it and not try to substitute it.

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.