J'essaie de rediriger vers une autre page une fois qu'un csv a été généré en cliquant sur le bouton soumettre. Jusqu'à présent, quand je clique sur le bouton, il envoie le CSV et il me donne le message "Succès" qui me fait penser que ça fonctionne bien.Php redirection ne fonctionne pas sur la soumission
Cependant, ce que je veux vraiment que la page redirige après la soumission a été faite. J'ai ajouté l'en-tête (emplacement:) dans l'instruction else, mais cela ne fait rien.
Quelqu'un peut-il m'aider s'il vous plaît?
if (isset($_POST['submit'])) {
function send_csv_mail ($csvData, $body, $to = '[email protected]', $subject = 'Test email with attachment', $from = '[email protected]') {
global $post;
$user_id = get_current_user_id();
// This will provide plenty adequate entropy
$multipartSep = '-----'.md5(time()).'-----';
// Arrays are much more readable
$headers = array(
"From: $from",
"Reply-To: $from",
"Content-Type: multipart/mixed; boundary=\"$multipartSep\""
);
// Make the attachment
$attachment = chunk_split(base64_encode(create_csv_string($csvData)));
// Make the body of the message
$body = "--$multipartSep\r\n"
. "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\r\n"
. "Content-Transfer-Encoding: 7bit\r\n"
. "\r\n"
. "$body\r\n"
. "--$multipartSep\r\n"
. "Content-Type: text/csv\r\n"
. "Content-Transfer-Encoding: base64\r\n"
. "Content-Disposition: attachment; filename=\"".date('Y-m-d')."-".str_replace(' ', '-', strtolower(get_user_meta($user_id, "wpcf-branch-active", true)))."-file.csv\"\r\n"
. "\r\n"
. "$attachment\r\n"
. "--$multipartSep--";
// Send the email, return the result
return @mail($to, $subject, $body, implode("\r\n", $headers));
}
$array = array(
array("Code", "Product Category", "Product Family", "Description", "Quantity", "Bay"),
);
send_csv_mail($array, "Hello World!!!\r\n This is simple text email message.");
if(!send_csv_mail) {
echo "Error";
}
else {
echo "success";
Header("Location: somewhere.php");
die();
}
}