Hi everyone,
I have a problem with a form that does not work.
In my main file called dashboard.php I have menu buttons which when you click on each one
it calls a javascript function. The functions contain ajax which opens a specific php page and displays the content of this page in a DIV inside dashboard.php
One button calls a file named… reset_admin_password.php which shows a form.
But when I click the form submit button the page only refreshes… if (isset($_POST[‘submit’])){
seems to be false and the remaining code does not get executed.
It seems that the POST call is out of scope?
This form appears inside a div inside dashboard.php
<?php include('reset_admin_connect.php'); // Includes Login Script ?>Admin Password
<form method="" id="form" name="adminform">
<div class="form-group" style="color: black;">
<input id="emailh" name="emailh" style="display: none;">
<label for="current_pw">Current Password:</label>
<input type="input" class="form-control" id="current_pw" placeholder="" name="current_pw">
<label for="password1">New Password:</label>
<input type="password" class="form-control" id="password1" placeholder="" name="password1">
<label for="password2">Confirm Password:</label>
<input type="password" class="form-control" id="password2" placeholder="" name="password2">
<button name="submit" type="submit" >Submit</button>
<div id="stop"></div>
</div>
</form>
</div>
</div>
<div class="col-md-4 col-sm-3 col-xs-12"></div>
</div>
</div>
------------------- reset_admin_connect.php --------------------
<?php session_start(); $error=''; // Variable To Store Error Message echo $_POST[lmem]; if (isset($_POST['submit'])){ echo 'hello henk'; if (empty($_POST['current_pw']) || empty($_POST['password1']) || empty($_POST['password2'])) { $error = "Fields cannot be empty"; }else{ // Define $username and $password $current_pw = $_POST['current_pw']; $password1 = $_POST['password1']; $password2 = $_POST['password2']; $username = $_SESSION['admin_user']; include ('../con/pdo_connect.php'); $query = $conn->prepare("SELECT password FROM admin WHERE username=?"); $query->execute($username); if ($password1 != $password2) { $error = "Both passwords need to match"; }else{ if($query->fetchColumn() === $current_pw){ //$column_name = $current_pw; $stmt = $conn->prepare("UPDATE admin SET password= ?") ->execute($password1); $stmt = null; //$_SESSION['login_user'] = $username; header("location: dashboard.php"); }else{ $error = "Username or password is invalid"; } } } } ?>