Hello,
I am new to some of the rules to PHP as far as what you can POST or SEND via forms in PHP.
I am attempting to change the location of a page via the header() function and basically redirect to another page if the weather is inclimate at an outdoor events center.
Currently what I have is two different submit buttons that would post the header() redirect based on if the weather is good or bad.
Ex.
<div style="width:220px; height:50px;">
<form method="POST" action="../../weather.php">
<input type="submit" value="Good Weather" name="weather_good" /> <input type="submit" value="Bad Weather" name="weather_bad" />
</form>
</div>
Then the processing for the form is this file -
<?php
if(isset($_POST['weather_good'])){
$myFile = "../myfile.php";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = echo "<?php header ('Location:fall_festival/index.php'); ?>";
fwrite($fh, $stringData);
fclose($fh);
echo "Page Updated";
}
else if(isset($_POST['weather_bad'])){
$myFile = "../myfile.php";
$fh = fopen($myFile, 'w') or die("can't open file");
$link = "header('Location:fall_festival/weather/index.php');" ;
$stringData = $link;
fwrite($fh, $stringData);
fclose($fh);
echo "Page Updated";
}
?>
The file doesn't return an error when it's processed but it also doesn't update the file header and redirect to the proper page. Thanks for your time and help!