0

i have this form. when user hit sumbit button i want to run changepassword.php

<form action = 'changepassword.php' method = 'POST'>
    Old password: <input type='password' name='old_password'><br/>
    New password: <input type='password' name = 'new_password'><br/>
    Confirm password: <input type='password' name = 'confirm_new_password'><br/>
    <input type='submit'  value='Change password'>
</form>

so when user hit submit i want to run this if statment. for some reason it doesnt go in this if statment.

    if(isset($_POST['submit']))
    { ... }

full code below.---------------------------------------------------------------------------------------------------

<?php
session_start();
include("connect.php");

$user = $_SESSION['username'];

if($user)
{
    //user is logged in
    if(isset($_POST['submit']))
    {
        echo "work dam ist";
        //checkfields
        $old_password = md5($_POST['old_password']);
        $new_password = md5($_POST['new_password']);
        $confirm_new_password = md5($_POST['confirm_new_password']);

        echo $old_password/$new_password/$confirm_new_password;

        $queryget = mysql_query("SELECT password FROM user WHERE username = '$user'") or die("query didnt work");
        $row = mysql_fetch_assoc($queryget);    
        $old_passworddb = $row['password']; //new variable(old_passworddb)

            //check old password
            if($old_password == $old_passworddb)
            {
                //check two new passwords
                if($new_password == $confirm__new_password)
                {
                    //Success
                    //put new password in data base
                    $querychange = mysql_query("
                    UPDATE user SET password = '$new_password' WHERE username = '$user'");
                    session_destroy();
                    die ("Your password has been changed. <a href='index.php'> Return </a> to the main page");
                }
                else
                    die("New password dont match");

            }
            else
                die("Old password dont match");
    }
}
else
{
    die("you must be logged in to change your password!");
}
?>



<form action = 'changepassword.php' method = 'POST'>
    Old password: <input type='password' name='old_password'><br/>
    New password: <input type='password' name = 'new_password'><br/>
    Confirm password: <input type='password' name = 'confirm_new_password'><br/>
    <input type='submit'  value='Change password'>
</form>
3
Contributors
4
Replies
10
Views
5 Years
Discussion Span
Last Post by hwoarang69
0

<input type='submit' name='submit' value='Change password'>

use var_dump($_POST); to investigate.

Edited by devgutt

0

this is so wired it works. but on my other code it doesnt work.
thanks, smeage13

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.