i trying to update my database field when form submitted , and then redirect to a page with header function , but page can't redirect and stay . what's the problem ?
session_start();
include("database.php");
if(isset($_POST["submit"])){
$address = $_POST["address"];
$message = $_POST["message"];
$id = $_SESSION["id"];
// custom function
$connect = connectToDatabase();
$database = $connect->prepare("UPDATE users SET address = :address , message = :message WHERE id = :id ");
$database->bindParam(":address", $address);
$database->bindParam(":message", $message);
$database->bindParam(":id", $id);
$success = $database -> execute() ;
if($success){
header("location:../panel/");
exit;
}
}else{
header("location:../panel/");
exit;
}
There are two things you can proceed and see, what works :
1> In your form element add data-ajax=false.( This fixes the issue with jquery mobile)
2> Instead of relative URI use absolute URI as argument.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.