Jump to content
Fórum Script Brasil
  • 0

Erro "Parse Error" T_VARIABLE


Douglas Mion

Question

Boa noite amigos, sou novo em PHP e estou tentando fazer um script para mudar a senha no banco de dados sem que o mesmo esteja logado, ou seja informando "usuario", "senha antiga", "senha-nova" e "confirmar a senha".

Pois bem criei os dois arquivos o "config.php" e o "senha.php" porém logo assim que tentei conectar ele fui recebido com o erro:

Parse error: syntax error, unexpected T_VARIABLE in /home/a9040706/public_html/pass/senha.php on line 9

Não consigo achar erro algum na linha 9 :\

Então estou postando aqui para vê se vocês acham esse erro pra mim.

config.php

<?
$banco = "ragnarok_eathena_main";
$usuario = "doug...";
$senha = "sans...";
$hostname = "ragnarok...";
$conn = mysql_connect($hostname,$usuario,$senha); mysql_select_db($banco) or die( "Não foi possível conectar ao banco MySQL");
if (!$conn) {echo "Não foi possível conectar ao banco MySQL.
"; exit;}
else {echo "Parabéns!! A conexão ao banco de dados ocorreu normalmente!.
";}
mysql_close();
?>
senha.php
<?php
include('config.php')
// This script will check that the current username and password match and if it does
// it checks that the $newpassword and the $confirmpassword match before inserting the
// $newpassword in the DB.


// Form input variables
$username = mysql_real_escape_string($_POST['userid']);
$password = mysql_real_escape_string($_POST['user_pass']);
$newpassword = mysql_real_escape_string($_POST['newpassword']);
$confirmpassword = mysql_real_escape_string($_POST['confirmpassword']);

if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
} else {
$result = mysql_query("SELECT pass FROM login WHERE usr='$username' and pass = '".md5($password)."'")or die("Query failed: " . mysql_error());
if(mysql_num_rows($result)){
    if($newpassword==$confirmpassword){
        $sql=mysql_query("UPDATE login SET pass='".md5($newpassword)."' where usr='$username'");
        if($sql)
        {
                echo "Password Changed";
        }
        else
        {
            // In case when problem while updating your new password
           echo "Error changing password, please email webmaster@signalwarrant.com";
        }
    } else {
        // In case when new-password and retype-password do not match
        echo "New and confirmed password do not match please try again.";
    }
    } else {
    // In case of you have not correct User name and password
        echo "Current username and password do no match.";
    }
}
?> 

<div class="pageContent">
    <div id="main">
        <div class="container">
        <h2>text goes here.</h2>
        </div>
            <div class="container">
            <?php
                if($_SESSION['id']){
                echo '<form action="" method="post">';
                echo '<h2>Username: </h2><input type="text" name="userid" size="50" maxlength="255"><br/>';
                echo '<h2>Password: </h2><input type="text" name="user_pass" size="50" maxlength="255"><br/>';
                echo '<h2>New Password: </h2><input type="text" name="newpassword" size="50" maxlength="255"><br/>';
                echo '<h2>Confirm Password: </h2><input type="text" name="confirmpassword" size="50" maxlength="255"><br/>';
                echo '<input type="submit" name="submit" value="Change Password">';
                echo '</form>';
                } else {
                echo '<h1>Please, <a href="index.php">login</a> and come back later!</h1>';
                }
            ?>
            </div>
      <div class="container tutorial-info">
      Footer goes here.
      </div>
    </div>
</div>

Desde já, agradeço a ajuda de vocês.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...