visualupload

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
ier
Posts: 67
Joined: Sun Jan 10, 2010 7:32 pm

visualupload

Post by ier »

He guys I have a problem with a script from phpacademy can someone help me I post the script here
the problem is this

Code: Select all

Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\phpacademy\visualupload\register.php  on line 85
here is the script

Code: Select all

<?php

include("design/header.php");
require("connect.php");

if ($_POST['submit'])
{
  $firstname =       $_POST['firstname'];
  $lastname =        $_POST['lastname'];
  $username =        $_POST['username'];
  $password =        $_POST['password'];
  $password_repeat = $_POST['password_repeat'];
  
  $dob_year =        $_POST['dob_year'];
  $dob_month =       $_POST['dob_month'];
  $dob_day =         $_POST['dob_day'];

  $gender =          $_POST['gender'];
  
  if (
  $firstname&&
  $lastname&&
  $username&&
  $password&&
  $password_repeat&&
  $dob_year&&
  $dob_month&&
  $dob_day&&
  $gender)
  {
    
          
          if (strlen($firstname)>25 || strlen($lastname)>25 || strlen($username)>25)
              echo "Firstname, lastname and username must be no more than 25 characters.";
          else
          {
            

            if (strlen($password)>25||strlen($password)<6)
               echo "Password must be between 6 and 25 characters.";
            else
            {
             
             

              if (is_numeric($dob_year)&&is_numeric($dob_month)&&is_numeric($dob_day)&&$dob_month)
              {

                if (strlen($dob_year)>4||strlen($dob_month)>2||strlen($dob_day)>2)
                   echo "Date of birth year must be 4 characters, month and day must be 2.";
                else
                    {
                  
                        
                        if ($gender=="Male"||$gender="Female")
                        {


                         if ($password==$password_repeat)
                         {
                           
                            if ($dob_month>12||$dob_day>31)
                               echo "Date of birth month or day is bigger than expected!";
                            else
                            {
                              $dob_db = "$dob_year-$dob_month-$dob_day";
                           $password_db = md5($password);

                            switch ($gender)
                            {
                              case "Male":
                              $gender_db = "M";
                              break;
                              case "Female":
                              $gender_db = "F";
                              break;
                            }

                            $register = mysql_query("INSERT INTO users VALUES ('','$firstname','$lastname','$username','$password_db','$dob_db','$gender_db')");
                            echo "Success!";
                              


                         }     
                         else
                             echo "Passwords do not match!";

                        }
                        else
                            echo "Gender must be Male or Female!";

                    }


              }
              else
                  echo "Date of birth must be in number form. For example, 1989/11/16";

            }


          }

  }
  else
      echo "Missing field! Please fill in all fields!";

}
else
    echo "Please enter your details and click Register.";

?>

<form action='register.php' method='POST'>

      <table width='60%'>
             <tr>
                 <td width='40%' align='right'>
                <font size='2' face='arial'>Firstname:
                 </td>
                 <td>
                 <input type='text' value='<?php echo $firstname; ?>' name='firstname' maxlength='25'>
                 </td>
             </tr>
             <tr>
                 <td width='40%' align='right'>
                <font size='2' face='arial'>Lastname:
                 </td>
                 <td>
                 <input type='text' value='<?php echo $lastname; ?>' name='lastname' maxlength='25'>
                 </td>
             </tr>
             <tr>
                 <td width='40%' align='right'>
                <font size='2' face='arial'>username:
                 </td>
                 <td>
                 <input type='text' value='<?php echo $username; ?>' name='username' maxlength='25'>
                 </td>
             </tr>
             <tr>
                 <td width='40%' align='right'>
                <font size='2' face='arial'>password:
                 </td>
                 <td>
                 <input type='password' name='password' maxlength='25'>
                 </td>
             </tr>
              <tr>
                 <td width='40%' align='right'>
                <font size='2' face='arial'>Repeat password:
                 </td>
                 <td>
                 <input type='password' name='password_repeat' maxlength='25'>
                 </td>
             </tr>
             <tr>
                 <td width='40%' align='right'>
                <font size='2' face='arial'>Date of birth:
                 </td>
                 <td>
                 <input type='text' name='dob_year' maxlength='4' size='3' value='<?php if ($dob_year) echo $dob_year; else echo "YYYY";?>'> / <input type='text' name='dob_month' maxlength='2' size='1' value='<?php if ($dob_month) echo $dob_month; else echo "MM";?>'> / <input type='text' name='dob_day' maxlength='2' size='1' value='<?php if ($dob_day) echo $dob_day; else echo "DD";?>'>
                 </td>
             </tr>
             <tr>
                 <td width='40%' align='right'>
                <font size='2' face='arial'>Gender:
                 </td>
                 <td>
                 <select name='gender'>
                         <option>Male</option>
                         <option>Female</option>
                 </select>
                 </td>
             </tr>

      </table>
      
      <div align='right'><input type='submit' name='submit' value='register'>

</form>

<?php

include("design/footer.php");

?>
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: visualupload

Post by Falken »

The if statesments at lines 20-110 is messed up, one of the look like this:

if(statement)
{

}
else
{
}
else
{
}

You can only have ONE else for each if statement. Not tested it, but I would guess you want the code like this (changed a few lines around lines 80-90):

Code: Select all

    <?php

    include("design/header.php");
    require("connect.php");

    if ($_POST['submit'])
    {
      $firstname =       $_POST['firstname'];
      $lastname =        $_POST['lastname'];
      $username =        $_POST['username'];
      $password =        $_POST['password'];
      $password_repeat = $_POST['password_repeat'];
     
      $dob_year =        $_POST['dob_year'];
      $dob_month =       $_POST['dob_month'];
      $dob_day =         $_POST['dob_day'];

      $gender =          $_POST['gender'];
     
      if (
      $firstname&&
      $lastname&&
      $username&&
      $password&&
      $password_repeat&&
      $dob_year&&
      $dob_month&&
      $dob_day&&
      $gender)
      {
       
             
              if (strlen($firstname)>25 || strlen($lastname)>25 || strlen($username)>25)
                  echo "Firstname, lastname and username must be no more than 25 characters.";
              else
              {
               

                if (strlen($password)>25||strlen($password)<6)
                   echo "Password must be between 6 and 25 characters.";
                else
                {
                 
                 

                  if (is_numeric($dob_year)&&is_numeric($dob_month)&&is_numeric($dob_day)&&$dob_month)
                  {

                    if (strlen($dob_year)>4||strlen($dob_month)>2||strlen($dob_day)>2)
                       echo "Date of birth year must be 4 characters, month and day must be 2.";
                    else
                        {
                     
                           
                            if ($gender=="Male"||$gender="Female")
                            {


								if ($password==$password_repeat)
								 {
								   
									if ($dob_month>12||$dob_day>31)
									   echo "Date of birth month or day is bigger than expected!";
									else
									{
									  $dob_db = "$dob_year-$dob_month-$dob_day";
								   $password_db = md5($password);

									switch ($gender)
									{
									  case "Male":
									  $gender_db = "M";
									  break;
									  case "Female":
									  $gender_db = "F";
									  break;
									}

									$register = mysql_query("INSERT INTO users VALUES ('','$firstname','$lastname','$username','$password_db','$dob_db','$gender_db')");
									echo "Success!";
									 


									}     
								}
								else
									 echo "Passwords do not match!";
							}
                            else
                                echo "Gender must be Male or Female!";

                        


                  }
                  else
                      echo "Date of birth must be in number form. For example, 1989/11/16";

                }


              }

      }
      else
          echo "Missing field! Please fill in all fields!";

    }
    else
        echo "Please enter your details and click Register.";

    ?>

    <form action='register.php' method='POST'>

          <table width='60%'>
                 <tr>
                     <td width='40%' align='right'>
                    <font size='2' face='arial'>Firstname:
                     </td>
                     <td>
                     <input type='text' value='<?php echo $firstname; ?>' name='firstname' maxlength='25'>
                     </td>
                 </tr>
                 <tr>
                     <td width='40%' align='right'>
                    <font size='2' face='arial'>Lastname:
                     </td>
                     <td>
                     <input type='text' value='<?php echo $lastname; ?>' name='lastname' maxlength='25'>
                     </td>
                 </tr>
                 <tr>
                     <td width='40%' align='right'>
                    <font size='2' face='arial'>username:
                     </td>
                     <td>
                     <input type='text' value='<?php echo $username; ?>' name='username' maxlength='25'>
                     </td>
                 </tr>
                 <tr>
                     <td width='40%' align='right'>
                    <font size='2' face='arial'>password:
                     </td>
                     <td>
                     <input type='password' name='password' maxlength='25'>
                     </td>
                 </tr>
                  <tr>
                     <td width='40%' align='right'>
                    <font size='2' face='arial'>Repeat password:
                     </td>
                     <td>
                     <input type='password' name='password_repeat' maxlength='25'>
                     </td>
                 </tr>
                 <tr>
                     <td width='40%' align='right'>
                    <font size='2' face='arial'>Date of birth:
                     </td>
                     <td>
                     <input type='text' name='dob_year' maxlength='4' size='3' value='<?php if ($dob_year) echo $dob_year; else echo "YYYY";?>'> / <input type='text' name='dob_month' maxlength='2' size='1' value='<?php if ($dob_month) echo $dob_month; else echo "MM";?>'> / <input type='text' name='dob_day' maxlength='2' size='1' value='<?php if ($dob_day) echo $dob_day; else echo "DD";?>'>
                     </td>
                 </tr>
                 <tr>
                     <td width='40%' align='right'>
                    <font size='2' face='arial'>Gender:
                     </td>
                     <td>
                     <select name='gender'>
                             <option>Male</option>
                             <option>Female</option>
                     </select>
                     </td>
                 </tr>

          </table>
         
          <div align='right'><input type='submit' name='submit' value='register'>

    </form>

    <?php

    include("design/footer.php");

    ?>
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: visualupload

Post by SpiritWebb »

Moved topic to Help and Support.
Image

Image
User avatar
ier
Posts: 67
Joined: Sun Jan 10, 2010 7:32 pm

Re: visualupload

Post by ier »

thank you but now I have the following problem when I click on the register, he dont checks of hé is allredy on the database
Post Reply

Return to “Advanced Help and Support”