View Single Post
Old 03-05-2012, 07:07 PM   PM User | #8
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,667
Thanks: 45
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Done within 5 seconds in Notepad++ using the tip in the codingstyles link in my signature - you might find that a helpful read

The extra } was actually on line 124. Presumably this was paired up with the commented out 'else' code under your session_start()?

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php session_start();
/*if (empty($pag)){
  $pag=0;}
  else{ */
   
$pag $_GET['pag'];//}

  
$email $_SESSION['email_aluno'];

 if (
$pag==0) {
    
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<link href="oneColFixCtrHdr.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="container">
  <div class="header">
    <div align="center"><img src="Logotipo Escola VRSA.jpg" alt="Insert Logo Here" name="Insert_logo" width="99" height="94" id="Insert_logo" style="background: #C6D580; display:block;" />  <a href="#">Rede Social da Escola Secundária de Vila Real de Santo António</a></div> 

    <!-- end .header --></div>
    <input onclick="history.back(-1)" type="button" value="Retroceder!" /><br>
    <table border='2'> <?php
       
echo "<form action =\"mudar_password_aluno.php?pag=1\" method=\"POST\">"?>
            <tr>
            <td colspan='2' align='center'><h3>Mudar Password</h3></td>
            </tr>
            <tr>
            <td>Password antiga:</td>
            <td><input type='password' name='password_a'></td>
            </tr>
            <tr>
            <td>Nova password:</td>
            <td><input type='password' name='password_n'></td>
            </tr>
            <tr>
            <td>Repetir Nova Password:</td>
            <td><input type='password' name='repetir_password'></td>
            </tr>
            </table>
            <p><input type='submit' name='submit' value='Mudar a Password'></p>
      </form>

  <?
}  
else
{
   
$password_a $_POST['password_a'];
   
$password_n $_POST['password_n'];
   
$repetir_password $_POST['repetir_password'];
   
$pass_velha_BD$_SESSION['password'];

    if (
$password_a == $pass_velha_BD)
    {
       if (
$repetir_password == $password_n)
        {
          if ((
strlen($password_n)>=6) and (strlen($password_n)<=25))
            {
              
$connect mysql_connect ("localhost" "root" "") or die("Não pôde conectar!");
              
mysql_select_db ("rsesvrsa") or die ("Não pôde encontrar a base de dados");
              
$sql"UPDATE alunos SET password = md5('$password_n') WHERE email_aluno='$email'";
              
$resultado mysql_query($sql);
               if (!
$resultado)
                {     
?>

                    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
                    alert ("Não foi possível mudar a password")
                    </SCRIPT>

                    <?php
                
}
                else 
                {
                    
?>
                    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
                    alert ("A password foi correctamente mudada")
                    </SCRIPT>
                    <?php
                    
echo "<meta HTTP-EQUIV='refresh' CONTENT='0;URL=login_alu.php'>";
                }
                 echo 
"<a href='login.php'>Voltar</a>";
             }
        }
//<-- THIS IS THE LINE 90
             
else 
            {
             
?>
             <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
             alert ("A password deverá conter entre 6 e 25 caracteres")
             </SCRIPT>
             <?php
             
echo "<meta HTTP-EQUIV='refresh' CONTENT='0;URL=mudar_password_aluno.php'>";
            }
        }
            else 
        {
         
?>

          <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
          alert ("A password repetida não coincide")
          </SCRIPT>

          <?php
          
echo "<meta HTTP-EQUIV='refresh' CONTENT='0;URL=mudar_password_aluno.php'>";
        }
    }
      else 
    {
      
?>
       <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
       alert ("A password actual que foi introduzida não está cerrecta")
       </SCRIPT>

       <?php
       
echo "<meta HTTP-EQUIV='refresh' CONTENT='0;URL=mudar_password_aluno.php'>";
    }
?>


    <!-- end .content --></div>
  <div class="footer">
    <p>©2011 Hugo Mendonça</p>
    <!-- end .footer --></div>
  <!-- end .container --></div>
</body>
</html>
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote