I have this form that reads data from my DB and displays it so the user can edit those values but when I click on the form button nothing happens.
Here is my code:
Everything starts when I called this function that gets the info to display my form
static function ctrEditUser()
{
if (isset($_POST["userEdit"])) {
$data = AdminControl::ctrGetUser($_POST["userEdit"]);
$nombre = $data['userNombre'];
$aPaterno = $data["userPaterno"];
$aMaterno = $data["userMaterno"];
$movil = $data["userMovil"];
$token = $data["token"];
include $_SERVER["DOCUMENT_ROOT"] . "/view/pages/admin/admin.form.php";
}
}
This is my form
<div class="row">
<form class="columnas" method="post" action="" id="form">
<div class="columna1">
<br>
<div class="form-group">
<label class="adminText" for="adminName">Nombre(s):</label>
<input type="text" class="formcontrol" name="adminName" id="adminName" value="<?php echo $nombre ?>">
</div>
<br><br>
<div class="form-group">
<label class="adminText" for="adminPaterno">Apellido Paterno:</label>
<input type="text" class="formcontrol" name="adminPaterno" id="adminPaterno" value="<?php echo $aPaterno ?>">
</div>
</div>
<div class="columna2">
<br>
<div class="form-group">
<label class="adminText" for="adminMaterno">Apellido Materno:</label>
<input type="text" class="formcontrol" name="adminMaterno" id="adminMaterno" value="<?php echo $aMaterno ?>">
</div>
<br><br>
<div class="form-group">
<label class="adminText" for="adminMovil">Teléfono Móvil:</label>
<input type="number" class="formcontrol" name="adminMovil" id="adminMovil" placeholder="DEBEN SER SOLO 10 DIGITOS" value="<?php echo $movil ?>">
<span class="validity"></span>
</div>
<br><br>
<div class="save-button row">
<div class="form-group columna2">
<input type="submit" class="sysButton" style="margin-left: 300px;" name="saveButton" value="actualizar"></input>
</div>
</div>
</div>
</form>
</div>
As you can see is just a simple form.
Once I clicked the button I need to check the form and then save the new updated data
<?php
if (isset($_POST['saveButton'])) {
..... more code here
but when I clicked the button nothing at all happens, it never enters the IF statement, i really don´t know what is going wrong.
I already saw a lot of examples and I thonk everything is ok.
I appreciate any help.
This code came from a previous page where you can see the $token and $_POST["userEdit"]
<form method="post" class="btn">
<input type="hidden" value="<?php echo $value["token"] ?>" name="markUserDeleted">
<button type="submit" id="buttonDelete" class="btn-danger"><i class="fas fa-trash-alt"></i></button>
</form>
<td>
<form method="post" class="btn">
<input type="hidden" value="<?php echo $value["token"] ?>" name="userEdit">
<button type="submit" id="buttonEdit"><i class="fas fa-edit"></i></button>
</form>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php
if (isset($_POST["markUserDeleted"])) {
$response = AdminControl::ctrDeleteUser();
} elseif (isset($_POST["userEdit"])) {
$response = AdminControl::ctrEditUser();
}
?>
</div>
</body>
This code shows a table with db data, when you click on the blue button calls the function AdminControl::ctrEditUser();