2010-03-18 2 views
0

비밀번호를 변경하는 코드를 만들었습니다. 이제 폼을 채우기 전에 오류가있는 것처럼 보입니다. 페이지 오류 메시지가 표시 :비밀번호 변경 오류

Parse error: parse error, unexpected $end in C:\Program Files\xampp\htdocs\e-Complaint(FYP)\userChangePass.php on line 222

를이 코드 : 양식

<?php # userChangePass.php 
//this page allows logged in user to change their password. 

$page_title='Change Your Password'; 

//if no first_name variable exists, redirect the user 
if(!isset($_SESSION['nameuser'])){ 

    header("Location: http://" .$_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF'])."/index.php"); 
    ob_end_clean(); 
    exit(); 

}else{ 

    if(isset($_POST['submit'])) {//handle form. 
     require_once('connectioncomplaint.php'); //connec to the database 

     //check for a new password and match againts the confirmed password. 
     if(eregi ("^[[:alnum:]]{4,20}$", stripslashes(trim($_POST['password1'])))){ 
      if($_POST['password1'] == $_POST['password2']){ 
       $p =escape_data($_POST['password1']); 
      }else{ 
       $p=FALSE; 
       echo'<p><font color="red" size="+1"> Your password did not match the confirmed password!</font></p>'; 
      } 
     }else{ 
      $p=FALSE; 
      echo'<p><font color="red" size="+1"> Please Enter a valid password!</font></p>'; 
     } 

     if($p){ //if everything OK. 

      //make the query 
      $query="UPDATE access SET password=PASSWORD('$p') WHERE userid={$_SESSION['userid']}"; 
      [email protected]_query($query);//run the query. 
      if(mysql_affected_rows() == 1) {//if it run ok. 

       //send an email,if desired. 
       echo '<p><b>your password has been changed.</b></p>'; 
       //include('templates/footer.inc');//include the HTML footer. 
       exit(); 

      }else{//if it did not run ok 

      $message= '<p>Your password could not be change due to a system error.We apolpgize for any inconvenience.</p><p>' .mysql_error() .'</p>'; 

      } 
      mysql_close();//close the database connection. 

      }else{//failed the validation test. 
       echo '<p><font color="red" size="+1"> Please try again.</font></p>'; 
      } 
     }//end of the main Submit conditional. 
    ?> 

그리고 코드 :

<h1>Change Your Password</h1> 
     <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 
     <fieldset> 
     <p><b>New Password:</b><input type="password" name="password1" size="20" maxlength="20" /> 
     <small>Use only letters and numbers.Must be between 4 and 20 characters long.</small></p> 
     <p><b>Confirm New Password:</b><input type="password" name="password2" size="20" maxlength="20" /></p> 
     </fieldset> 
     <div align="center"> <input type="submit" name="submit" value="Change My Password" /></div> 

</form><!--End Form--> 

답변

0

난 당신이 중 하나에 } 누락 있다고 생각하여 ?> 직전의 상태.

코드를 올바르게 들여 쓰기하면 쉽게 구분됩니다.

편집 : suspeced으로

, 다음과 같이 마지막 줄에 2에 } 추가 : 파일의 끝에 닫는 }을 놓치고

<?php # userChangePass.php 
//this page allows logged in user to change their password. 

$page_title='Change Your Password'; 

//if no first_name variable exists, redirect the user 
if(!isset($_SESSION['nameuser'])){ 

    header("Location: http://" .$_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF'])."/index.php"); 
    ob_end_clean(); 
    exit(); 

}else{ 

    if(isset($_POST['submit'])) {//handle form. 
     require_once('connectioncomplaint.php'); //connec to the database 

     //check for a new password and match againts the confirmed password. 
     if(eregi ("^[[:alnum:]]{4,20}$", stripslashes(trim($_POST['password1'])))){ 
      if($_POST['password1'] == $_POST['password2']){ 
       $p =escape_data($_POST['password1']); 
      }else{ 
       $p=FALSE; 
       echo'<p><font color="red" size="+1"> Your password did not match the confirmed password!</font></p>'; 
      } 
     }else{ 
      $p=FALSE; 
      echo'<p><font color="red" size="+1"> Please Enter a valid password!</font></p>'; 
     } 

     if($p){ //if everything OK. 

      //make the query 
      $query="UPDATE access SET password=PASSWORD('$p') WHERE userid={$_SESSION['userid']}"; 
      [email protected]_query($query);//run the query. 
      if(mysql_affected_rows() == 1) {//if it run ok. 

       //send an email,if desired. 
       echo '<p><b>your password has been changed.</b></p>'; 
       //include('templates/footer.inc');//include the HTML footer. 
       exit(); 

      }else{//if it did not run ok 

      $message= '<p>Your password could not be change due to a system error.We apolpgize for any inconvenience.</p><p>' .mysql_error() .'</p>'; 

      } 
      mysql_close();//close the database connection. 

      }else{//failed the validation test. 
       echo '<p><font color="red" size="+1"> Please try again.</font></p>'; 
      } 
     }//end of the main Submit conditional. 
    } 
    ?> 
1

. 다음 문장의 else는 폐쇄되지 않습니다이 줄 }//end of the main Submit conditional.

if(!isset($_SESSION['nameuser'])){ 

    header("Location: http://" .$_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF'])."/index.php"); 
    ob_end_clean(); 
    exit(); 

}else{ 

귀하의 최종 마감 한 번 더 if이 폐쇄되는 잎이 줄 if(isset($_POST['submit'])) {//handle form.을 닫는.

0

$ _SESSION [ 'nameuser']을 (를) 확인할 때 첫 번째 if/else 블록을 닫으려면 a가 없습니다.

<?php # userChangePass.php 
//this page allows logged in user to change their password. 

$page_title='Change Your Password'; 

//if no first_name variable exists, redirect the user 
if(!isset($_SESSION['nameuser'])){ 

    header("Location: http://" .$_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF'])."/index.php"); 
    ob_end_clean(); 
    exit(); 

}else{ 

    if(isset($_POST['submit'])) {//handle form. 
     require_once('connectioncomplaint.php'); //connec to the database 

     //check for a new password and match againts the confirmed password. 
     if(eregi ("^[[:alnum:]]{4,20}$", stripslashes(trim($_POST['password1'])))){ 
      if($_POST['password1'] == $_POST['password2']){ 
       $p =escape_data($_POST['password1']); 
      }else{ 
       $p=FALSE; 
       echo'<p><font color="red" size="+1"> Your password did not match the confirmed password!</font></p>'; 
      } 
     }else{ 
      $p=FALSE; 
      echo'<p><font color="red" size="+1"> Please Enter a valid password!</font></p>'; 
     } 

     if($p){ //if everything OK. 

      //make the query 
      $query="UPDATE access SET password=PASSWORD('$p') WHERE userid={$_SESSION['userid']}"; 
      [email protected]_query($query);//run the query. 
      if(mysql_affected_rows() == 1) {//if it run ok. 

       //send an email,if desired. 
       echo '<p><b>your password has been changed.</b></p>'; 
       //include('templates/footer.inc');//include the HTML footer. 
       exit(); 

      }else{//if it did not run ok 

      $message= '<p>Your password could not be change due to a system error.We apolpgize for any inconvenience.</p><p>' .mysql_error() .'</p>'; 

      } 
      mysql_close();//close the database connection. 

      }else{//failed the validation test. 
       echo '<p><font color="red" size="+1"> Please try again.</font></p>'; 
      } 
     }//end of the main Submit conditional. 
} // end session check 
?> 
관련 문제