Thread: Form error

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0

    Form error


    Hi,
    i have a problem when i submit a form.
    <form action="" method="post">
    <table><tr><td> Password Antiga*:</td><td><input type ="password" name="password_antiga"></td></tr>
    <tr><td> Nova Password*:</td><td><input type ="password" name="password_nova"></td></tr>
    <tr><td> Confirmar Nova Password*:</td><td><input type ="password" name="confirmar_password_nova"></td></tr>
    <tr><td></td><td><input id="submit" type="submit" class="btn btn-primary" value="Alterar Password"></td><td><a href="index.php" class="btn btn-primary" >Cancelar</a></td></tr>
    </table>
    </form>
    Even though i am submiting the form whith the method post,
    the variables show up in the url. That´s no all, the array $_POST is empty when i submit the form.
    It seams that the action having some problem being executed.
    The form is not submited, it seams.
    I can´t figure out what´s the problem.

    Some help would be great !!!

    Thanks,
    Paulo Torres
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,066
    Rep Power
    9398
    Might you be using a nested <form>? What's the rest of the HTML? If it really was as you posted without any hidden gotchas then it will not put the values in the URL and $_POST will have everything.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0

    The rest of the code


    <!DOCTYPE html>
    <html lang="en">

    <?php include 'core/init.php';?>
    <?php protect_page(); ?>
    <?php include 'includes/head.php';?>
    <?php
    if (empty($_POST)===false){
    $required_fields=array('password_antiga','password_nova','confirmar_password_nova');
    foreach($_POST as $key=>$value){
    if (empty($value) && in_array($key,$required_fields)=== true){
    $errors[] = "Os campos marcados a * são obrigatórios";
    break 1;

    }

    }
    if(md5($_POST['password_antiga']) === $user_data['password']){
    if ($_POST['password_nova'] !== $_POST['confirmar_password_nova']){
    $errors[] = 'As novas passwords introduzidas não são iguais!';
    } else if (strlen($_POST['password_nova'])<6){
    $errors[] = 'O tamanho da password deve ser superior a 6 caracteres!';
    }
    }else
    {
    $errors[] = 'A password atual não está correta!';
    }
    }
    if(empty($_POST)===false && empty($errors)===true){
    $register_data=array(
    'password'=>$_POST['password']
    );
    change_password($session_user_id, $_POST['password_nova']);
    header('Location: index.php?successPassword');
    exit();

    }
    else if (empty($errors)===false)
    {
    echo '<div class="modal">
    <div class="modal-header">
    <h3>Ocorreram os seguintes erros.</h3>
    </div>
    <div class="modal-body">';
    echo output_errors($errors);
    echo ' </div>
    <div class="modal-footer">
    <a href="mudarPassword.php" class="btn btn-warning">Fechar</a>
    </div>
    </div>';
    }
    print_r($_POST);
    ?>
    <body>

    <?php include 'includes/header.php';?>
    <?php include 'includes/hero.php'; ?>
    <div class="container">
    <h1>Mudar Password</h1>
    <hr>

    <form action="" method="post">
    <table><tr><td> Password Antiga*:</td><td><input type ="password" name="password_antiga"></td></tr>
    <tr><td> Nova Password*:</td><td><input type ="password" name="password_nova"></td></tr>
    <tr><td> Confirmar Nova Password*:</td><td><input type ="password" name="confirmar_password_nova"></td></tr>
    <tr><td></td><td><input id="submit" type="submit" class="btn btn-primary" value="Alterar Password"></td><td><a href="index.php" class="btn btn-primary" >Cancelar</a></td></tr>
    </table>
    </form>

    <!-- Example row of columns -->

    <?php include 'includes/footer.php';?>

    </div> <!-- /container -->
    <?php include 'includes/javascript.php'; ?>



    </body>

    </html>
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,066
    Rep Power
    9398
    Still nothing that would cause this. What are the included files? What does protect_page() do?

    Check your server's access logs too. I suspect you'll see one request that POSTs to the page and then immediately after one that GETs with the values in the URL.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0

    My post is acting like a get


    It´s strange because my method = "post" but actually it´s acting like method="get".

    I can´t figure out the problem.
    I´m using bootstrap; i dont´t know if that´s the problem...

IMN logo majestic logo threadwatch logo seochat tools logo