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>