I am making a loan system in which a teacher will request a loan, which will record his identification number, the plate or serial number of the item he requested, the current date and the administrator who lent him the item at that moment, who it will be the user who has the session active.
The problem I have is when sending data, the browser does not give me any errors and when looking at the table in phpMyAdmin
the data is not inserted into the database.
This would be the form that would receive the data and send it to processPrestamo.php The values of $ Admin Y $ Instructor are of numeric type and $ element are of type String and $ date type date although I am inserting it as a string because the prepared query only allows me to specify with "i" for integer "s" for string, and "d" for double, in the database, If I have it specified as a date type, I do not know if there is a problem with the data.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
</head>
<body>
<form action="procesarPrestamo.php" method="post" accept-charset="utf-8">
Elemento: <input type="text" name="elemento"/>
Cedula: <input type="text" name="cedula"/>
<input type="submit" name="enviar" value="Enviar"/>
</form>
</body>
</html>
<?php
include_once 'conexion.php';
session_start();
date_default_timezone_set('America/Bogota');
$Admin = $_SESSION['user'];
$Instructor = $_POST['cedula'];
$Elemento = $_POST['elemento'];
$Fecha = date("d/m/Y");
if ($stmt = $mysqli->prepare("INSERT INTO prestamo VALUES(?,?,?,?)") ){
$stmt->bind_param("iiss",$Admin,$Instructor,$Elemento,$Fecha);
$stmt->execute();
$stmt->close();
} else{
echo "Error al ejecutar la sentencia preparada".$mysqli->error;
}
$mysqli = new Conexion();
?>