I got a HTML form on a wordpress website which executes a PHP script after submitting. That works fine, but after the PHP script is executed I need to redirect to another wordpress page, does anyone knows how I could do that?
Here's the HTML code on my Wordpress page:
<form action="[insert_php] include('wp-content/logindataupload.php');
[/insert_php]" method="post" >First name
<input name="field1" type="text" />
Name
<input name="field2" type="text" />
E-Mail
<input name="field3" type="text" />
<input type="submit" value="Submit" /></form>
And here's the code in the "logindataupload.php" file:
<?php
$path = 'wp-content/uploadhistory.txt';
if (isset($_POST['field1']) && isset($_POST['field2']) && isset($_POST['field3'])) {
$fh = fopen($path,"a+");
$string = $_POST['field1'].$_POST['field2'].'_'.$_POST['field3']."\n";
fwrite($fh,$string); // Write information to the file
fclose($fh); // Close the file
}
$path2 = 'wp-content/currentupload.txt';
file_put_contents($path2, "");
if (isset($_POST['field1']) && isset($_POST['field2']) && isset($_POST['field3'])) {
$fh = fopen($path2,"a+");
$string = $_POST['field1'].$_POST['field2'].'_'.$_POST['field3'];
fwrite($fh,$string); // Write information to the file
fclose($fh); // Close the file
}
?>
I'm quite new into PHP and I think I have to do the redirect in the "logindataupload.php" file. I already tried to insert the following behind the last "?>"
header("Location: http://page-i-want-to-redirect-to.com"); /* Redirect browser */
If something's missing, please tell me. Thank you very much.