Web Analytics Made Easy -
StatCounter have a problem with reg script look here to tell me whats wrong - CodingForum

Announcement

Collapse
No announcement yet.

have a problem with reg script look here to tell me whats wrong

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • have a problem with reg script look here to tell me whats wrong

    Parse error: parse error, unexpected T_STRING in /home/vhosts/globolwarfare.e2uhosting.com/testphp/login/register.php on line 16

    PHP Code:
    <?
    SESSION_START
    ();
    header("Cache-control:private");
    INCLUDE(
    'functions.php');

    if(
    $_GET['act'] == "") {
    if(
    $_SESSION['username']) {
    echo(
    "Your loggedin already!");
    } else {
    echo(
    "<table align='center'>
    <form action='?act=check' method='POST'>
    <tr><td>Username:</td><td><input type='text' name='username'></td></tr>
    <tr><td>Password:</td><td><input type='password' name='password'></td></tr>
    <tr><td>Password Confirm:</td><td><input type='password' name='password2'></td></tr>
    <tr><td>Country:</td><td>
    <select name="
    country">
    <option value="
    brazil">Rio de Janeiro - Brazil</option>
    <option value="
    russia">Moscow - Russia</option>
    <option value="
    usa">New York - USA</option>
    <option value="
    england">London - England</option>
    <option value="
    ireland">Dublin - Ireland</option>
    <option value="
    norway">Oslo-Norway</option>
    <option value="
    spain">Barcelona - Spain</option>
    <option value="
    germany">Berlin - Germany</option>
    <option value="
    india">New Delhi - India</option>
    </select>
    </td></tr>
    <tr><td>Email:</td><td><input type='text' name='email'></td></tr>
    <tr><td><input type='submit' name='submit' value='Login'></td></tr>
    </form>
    </table>"
    );
    }
    }
    if(
    $_GET['act'] == "check") {
    if(!
    $_POST['username'] || !$_POST['password'] || !$_POST['password2']); {
    echo(
    "<a href=\"javascript:history.go(-1)\">Go back and fill out all fields, correctly!</a>");
    } else {

    $username =$_POST['username'];
    $email =$_POST['email'];
    $country $_POST['country'];

    $check=mysql_query("SELECT * FROM `users` WHERE username = '$username'")or die(mysql_error());
    $Numb=mysql_num_rows($check);

    if(
    $Numb 0); {
    echo(
    "<a href=\"javascript:history.go(-1)\">Go back</a> username is taken!");
    } else {
    if(
    $password != $password2) {
    echo(
    "<a href=\"javascript:history.go(-1)\">Go back</a> your password's didnt match");
    } else {

    $username=addslashes($username);
    $password=md5($password);

    $INSERT=mysql_query("INSERT INTO `users`(userid,username,password,email,country) VALUES
    ('', '
    $username', '$password', '$email', '$country')")or die(mysql_error());
    echo(
    "<a href='login.php'>Login with ur username/password you registered with!</a><br />
    <B>Username:</B> 
    $username<br />
    <B>Password:</B> 
    $password2");
    }
    }
    }
    }
    ?>
    Last edited by sytodave88; Aug 2, 2005, 09:33 AM.

  • #2
    you need to escape your quotes eg.
    PHP Code:
    echo "<select name=\"country\">"
    instead of

    PHP Code:
    echo "<select name="country">"
    http://www.hazelryan.co.uk

    Comment


    • #3
      ...or use single quotes:
      PHP Code:
      echo '<select name="country">'
      double quotes go better with HTML.
      I'm not sure if this was any help, but I hope it didn't make you stupider.

      Experience is something you get just after you really need it.
      PHP Installation Guide Feedback welcome.

      Comment


      • #4
        the double quote on this line <select name="country"> is closing your echo statement.
        Instead of echoing it out, close your php tag and put the html, then reopen your php. Eg.
        PHP Code:
        if($_SESSION['username']) {
        echo("Your loggedin already!");
        } else {
        ?>
        Any html (you form) can go here, double and single quotes.
        <?php
        }
        }
        if(
        $_GET['act'] == "check") {
        Edit: Damn i took a long time to post!

        Comment


        • #5
          Tip: If you get a parse error, go to the line it says the error's on and look through the coding around it. Usually it's a missing quote, a missing ; or you didn't escape the double quotes.

          Escaping PHP when you put in HTML makes it so easy.
          I lost my signature, have you seen it?
          I have the power to erase you...

          Comment


          • #6
            know i am geting this error and i see nothing wrong Parse error: parse error, unexpected T_ELSE in /home/vhosts/globolwarfare.e2uhosting.com/testphp/login/register.php on line 37
            PHP Code:
            <?
            SESSION_START
            ();
            header("Cache-control:private");
            INCLUDE(
            'functions.php');

            if(
            $_GET['act'] == "") {
            if(
            $_SESSION['username']) {
            echo(
            "Your loggedin already!");
            } else {
            echo(
            "<table align='center'>
            <form action='?act=check' method='POST'>
            <tr><td>Username:</td><td><input type='text' name='username'></td></tr>
            <tr><td>Password:</td><td><input type='password' name='password'></td></tr>
            <tr><td>Password Confirm:</td><td><input type='password' name='password2'></td></tr>
            <tr><td>Country:</td><td>
            echo'<select name=\"country\">';
            echo'<option value=\"brazil\">Rio de Janeiro - Brazil</option>';
            echo'<option value=\"russia\">Moscow - Russia</option>';
            echo'<option value=\"usa\">New York - USA</option>';
            echo'<option value=\"england\">London - England</option>';
            echo'<option value=\"ireland\">Dublin - Ireland</option>';
            echo'<option value=\"norway\">Oslo-Norway</option>';
            echo'<option value=\"spain\">Barcelona - Spain</option>';
            echo'<option value=\"germany\">Berlin - Germany</option>';
            echo'<option value=\"india\">New Delhi - India</option>';
            </select>';
            </td></tr>
            <tr><td>Email:</td><td><input type='text' name='email'></td></tr>
            <tr><td><input type='submit' name='submit' value='Login'></td></tr>
            </form>
            </table>"
            );
            }
            }
            if(
            $_GET['act'] == "check") {
            if(!
            $_POST['username'] || !$_POST['password'] || !$_POST['password2']); {
            echo(
            "<a href=\"javascript:history.go(-1)\">Go back and fill out all fields, correctly!</a>");
            } else {
            $username =$_POST['username'];
            $email =$_POST['email'];
            $country $_POST['country'];

            $check=mysql_query("SELECT * FROM `users` WHERE username = '$username'")or die(mysql_error());
            $Numb=mysql_num_rows($check);

            if(
            $Numb 0); {
            echo(
            "<a href=\"javascript:history.go(-1)\">Go back</a> username is taken!");
            } else {
            if(
            $password != $password2) {
            echo(
            "<a href=\"javascript:history.go(-1)\">Go back</a> your password's didnt match");
            } else {

            $username=addslashes($username);
            $password=md5($password);

            $INSERT=mysql_query("INSERT INTO `users`(userid,username,password,email,country) VALUES
            ('', '
            $username', '$password', '$email', '$country')")or die(mysql_error());
            echo(
            "<a href='login.php'>Login with ur username/password you registered with!</a><br />
            <B>Username:</B> 
            $username<br />
            <B>Password:</B> 
            $password2");
            }
            }
            }
            }
            ?>

            Comment


            • #7
              This way you don't have to worry about any quotes marks.
              PHP Code:
              ...
              if($_GET['act'] == "") {
              if($_SESSION['username']) {
              echo("Your loggedin already!");
              } else {
              ?>
              <table align='center'>
              <form action='?act=check' method='POST'>
              <tr><td>Username:</td><td><input type='text' name='username'></td></tr>
              <tr><td>Password:</td><td><input type='password' name='password'></td></tr>
              <tr><td>Password Confirm:</td><td><input type='password' name='password2'></td></tr>
              <tr><td>Country:</td><td>
              <select name="country">
              <option value="brazil">Rio de Janeiro - Brazil</option>
              <option value="russia">Moscow - Russia</option>
              <option value="usa">New York - USA</option>
              <option value="england">London - England</option>
              <option value="ireland">Dublin - Ireland</option>
              <option value="norway">Oslo-Norway</option>
              <option value="spain">Barcelona - Spain</option>
              <option value="germany">Berlin - Germany</option>
              <option value="india">New Delhi - India</option>
              </select>
              </td></tr>
              <tr><td>Email:</td><td><input type='text' name='email'></td></tr>
              <tr><td><input type='submit' name='submit' value='Login'></td></tr>
              </form>
              </table>
              <?php
              }
              }
              ...
              EDIT:

              and the line 37 error (that i thought was somewhere else, oops) is the semi-colon on this line.
              PHP Code:
              if(!$_POST['username'] || !$_POST['password'] || !$_POST['password2']); {
              // it should be
              if(!$_POST['username'] || !$_POST['password'] || !$_POST['password2']) { 
              EDIT2: There's also the same mistake on line 47 (i think)
              PHP Code:
              if($Numb 0); {
              //should be
              if($Numb 0){ 
              Last edited by schleppel; Aug 2, 2005, 11:49 AM.

              Comment


              • #8
                thanx i have it working know

                Comment

                Working...
                X