www.webdeveloper.com
Results 1 to 4 of 4

Thread: PHP error

  1. #1
    Join Date
    May 2012
    Posts
    5

    PHP error

    Good morning, all. I'm sort of new at php and have been teaching myself with online tutorials and such. I'm getting the hang of it so far, but last night I ran into a problem that I can't seem to resolve. Here is the code below:

    Code:
    if ( (strlen($getemail) >= 7) && (strstr($getemail), '@') && (strstr($getemail), '.')){
          						require("connect.php");
          						
    						$query = mysql_query("SELECT * FROM members WHERE username='$getuser'");
    						$numrows = mysql_num_rows($query);
    						
    							if ($numrows == 0){
    								$query = mysql_query("SELECT * FROM members WHERE email='$getemail'");
    								$numrows = mysql_num_rows($query);
    								if ($numrows == 0){
    									
    									$password = md5(md5("[salt]".$password."[salt]"));
    									$date = date('F d, Y');
    									$code = md5(rand());
    									
    									mysql_query ("INSERT INTO members VALUES (
    									'', '$getuser', '$password', '$getemail', '', '$date', '0', '$code', '$getfirstname', '$getlastname', '$lastloginip', '$getbirthmonth', '$getbirthday', $getbirthyear', '$getgender'
    									)")
    									
    									$query = mysql_query("SELECT * FROM members WHERE username='$getuser'")
    								
    								}
    								else {
    								$errormsg = "There is already a user with that email address.";
    								}
    							}
    							else {
    							$errormsg = "There is already a user with that username.";
    							}
    
          						mysql_close();
          						}
          						else {
          						$errormsg = "You must enter a valid email address to register."
          						}
    The error I'm receiving is:

    "Parse error: syntax error, unexpected ',' in /[address here]/register.php on line 35"

    Line 35 is the very first line in the given code. I don't know what it's trying to tell me.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    PHP Code:
    if ( ( strlen($getemail) >= ) && ( strstr($getemail'@') ) && ( strstr($getemail'.') ) ){ 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    May 2012
    Posts
    5
    Thanks, NogDog! That fixed it! There were about 3 more syntax errors after that, but I was able to find them. I ran the code and another problem occurred that I'm unaware of. Whenever I fill out the form and click the submit button, I'm taken to a completely blank version of register.php and I don't know why it doesn't take me back to the form.

    PHP Code:
    <?php

    error_reporting
    (E_ALL E_NOTICE);

    ?>

    <html>

    <head>
    <title>XC - Registration</title>
    </head>

    <body>

    <?php

    if ($_POST['submitbtn']){
          
    $getuser $_POST['user'];
          
    $getemail $_POST['email'];
          
    $getpass $_POST['pass'];
          
    $getverifypass $_POST['verifypass'];
          
    $lastloginip $_SERVER['REMOTE_ADDR'];
          
    $getfirstname $POST['firstname'];
          
    $getlastname $_POST['lastname'];
          
    $getbirthmonth $_POST['birthmonth'];
          
    $getbirthday $_POST['birthday'];
          
    $getbirthyear $_POST['birthyear'];
          
    $getgender $_POST['gender'];

          if ( 
    $getuser){
                  if ( 
    $getemail){
                      if ( 
    $getpass){
                          if ( 
    $getverifypass){
                              if ( 
    $getpass === $getverifypass){
                                  if ( ( 
    strlen($getemail) >= ) && ( strstr($getemail'@') ) && ( strstr($getemail'.') ) ){                                          require('connect.php');
                                  
                            
    $query mysql_query("SELECT * FROM members WHERE username='$getuser'");
                            
    $numrows mysql_num_rows($query);
                            
                                if (
    $numrows == 0){
                                    
    $query mysql_query("SELECT * FROM members WHERE email='$getemail'");
                                    
    $numrows mysql_num_rows($query);
                                    if (
    $numrows == 0){
                                        
                                        
    $password md5(md5("salt".$getpass."salt"));
                                        
    $date date('F d, Y');
                                        
    $code md5(rand());
                                        
                                        
    mysql_query ("INSERT INTO members VALUES (
                                        '', '
    $getuser', '$password', '$getemail', '', '$date', '0', '$code', '$getfirstname', '$getlastname', '$lastloginip', '$getbirthmonth', '$getbirthday', $getbirthyear', '$getgender'
                                        )"
    );
                                        
                                        
    $query mysql_query("SELECT * FROM members WHERE username='$getuser'");
                                        
    $numrows mysql_num_rows($query);
                                        if (
    $numrows == 1){
                                            
                                            
    $site 'http://localhost';
                                            
    $webmaster 'XC Admin <admin@edit.com>';
                                            
    $headers 'From: $webmaster';    
                                            
    $subject 'Trancience: Activate your account';
                                            
    $message 'Thanks for registering. Click the link below to activate your account. \n $site/activate.php?user=$getuser&code=$code \n You must activate your account to login.';    
                                            
                                            if (
    mail($getemail$subject$message$headers)){
                                            
                                            
    $errormsg "You have been registered. You must activate your account with the activation link sent to <b>$getemail</b>.";
                                            
    $getuser '';
                                            
    $getemail '';
                                            
                                            }
                                            else
                                            
    $errormsg "An error has occurred. Your activation email was not sent.";
                                                                    
                                        }
                                        else
                                        
    $errormsg "An error has occurred. Your account was not created.";
                
                                    }
                                    else 
                                    
    $errormsg "There is already a user with that email address.";
                                    
                                }
                                else 
                                
    $errormsg "There is already a user with that username.";
                                

                                  
    mysql_close();
                                  }
                                  else 
                                  
    $errormsg "You must enter a valid email address to register.";
                                  
                              }
                              else 
                              
    $errormsg "Your passwords did not match.";
                              
                          }
                          else 
                          
    $errormsg "You must verify your password to register.";
                          
                      }
                      else 
                      
    $errormsg "You must enter a password to register.";
                      
                  }
                  else 
                  
    $errormsg "You must enter your email to register.";
                  
          }
          else
          
    $errormsg "You must enter your username to register.";
    }
    else 


    $form "<form action='register.php' method='post'><fieldset><b><legend>Player Information</legend></b>
    <table>
    <tr>
        <td colspan='2'><font color='red'>
    $errormsg</font></td>
    </tr>
    <tr>
        <td>First Name:</td>
        <td><input type='text' name='firstname' value='
    $getfirstname' /></td>
    </tr>
    <tr>
        <td>Last Name:</td>
        <td><input type='text' name='lastname' value='
    $getlastname' /></td>
    </tr>
    <tr>
            <td>Gender:</td>
            <td><select name='gender' value='
    $getgender'>
                <option selected value='male'>Male</option>
                <option value='female'>Female</option></td>
                </select>
          </tr>
    <tr>
            <td>Date of Birth:</td>
            <td>
              <select name='birthmonth' value='Month'>
                <option selected value='January'>January</option>
                <option value='February'> February</option>
                <option value='March'>March</option>
                <option value='April'>April</option>
                <option value='May'>May</option>
                <option value='June'>June</option>
                <option value='July'>July</option>
                <option value='August'>August</option>
                <option value='September'>September</option>
                <option value='October'>October</option>
                <option value='November'>November</option>
                <option value='December'>December</option>
          </select>
          <select name='birthday'>
                <option selected value='01'>01</option>
                <option value='02'>02</option>
                <option value='03'>03</option>
                <option value='04'>04</option>
                <option value='05'>05</option>
                <option value='06'>06</option>
                <option value='07'>07</option>
                <option value='08'>08</option>
                <option value='09'>09</option>
                <option value='10'>10</option>
                <option value='11'>11</option>
                <option value='12'>12</option>
                <option value='13'>13</option>
                <option value='14'>14</option>
                <option value='15'>15</option>
                <option value='16'>16</option>
                <option value='17'>17</option>
                <option value='18'>18</option>
                <option value='19'>19</option>
                <option value='20'>20</option>
                <option value='21'>21</option>
                <option value='22'>22</option>
                <option value='23'>23</option>
                <option value='24'>24</option>
                <option value='25'>25</option>
                <option value='26'>26</option>
                <option value='27'>27</option>
                <option value='28'>28</option>
                <option value='29'>29</option>
                <option value='30'>30</option>
                <option value='31'>31</option>
              </select>
              <input maxlength=4 name='birthyear' value='
    $getbirthyear' size=4> Format (month dd, yyyy)
    <tr>
        <td>Username:</td>
        <td><input type='text' name='user' value='
    $getuser' /></td>
    </tr>
    <tr>
        <td>Email:</td>
        <td><input type='text' name='email' value='
    $getemail' /></td>
    </tr>
    <tr>
        <td>Password:</td>
        <td><input type='password' name='pass' value='
    $getpass' /></td>
    </tr>
    <tr>
        <td>Verify:</td>
        <td><input type='password' name='verifypass' value='
    $getverifypass' /></td>
    </tr>
    <tr>
        <td></td>
        <td><input type='submit' name='submitbtn' value='Register' /></td>
    </tr>

    </table></fieldset>
    </form>"
    ;

    echo 
    $form;



    ?>
    </body>
    </html>

  4. #4
    Join Date
    Apr 2012
    Posts
    4
    This is because your form action takes you to register.php that is why. What do you mean it does not take you back to the form?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles