Hi guys,
I am looking for a solution. I have 6 variables that I want to assign true or false via a form set with radio buttons. The form on submit will write to a php page that will ultimatley be used by another php page via "include" to tell the script if these variables are on or off. I need to do this via a document save versus saving the true or false values in a database.
I have made the following code to do this
<?php
$cat_1 = $_POST["cat_1"];
//$man_1 = $_POST["man_1"];
//$new_1 = $_POST["new_1"];
//$find_1 = $_POST["find_1"];
//$info_1 = $_POST["info_1"];
if ($cat_1 == true){
$fp = fopen('data.php', 'w');
fwrite($fp, '<?php $cat_1 = true; ');}
else {
$fp = fopen('data.php', 'w');
fwrite($fp, '<?php $cat_1 = false; ');}
if ($man_1 == true)
fwrite($fp, '$man_1 = false');
fclose($fp);
echo "success";
?>
Note this only deals with one of the variables that needs to be checked (once i get the code working there is another 5 or 6!). When I submit my form I always get "false" no matter whether the result from the form is true..
The following is my form
<form method="POST" action="submit.php">
<!--webbot bot="SaveResults" U-File="_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p>On I Off</p>
<p><input type="radio" value="true" name="cat_1" checked>
<input type="radio" name="cat_1" value="false"> Categories</p>
<p><input type="radio" name="man_1" value="true" checked>
<input type="radio" name="man_1" value="false">
Manufactures</p>
<p><input type="radio" name="new_1" value="true" checked>
<input type="radio" name="new_1" value="false"> What's New</p>
<p><input type="radio" name="find_1" value="true" checked>
<input type="radio" name="find_1" value="false"> Quick
Find</p>
<p><input type="radio" name="info_1" value="true" checked>
<input type="radio" name="info_1" value="false">
Information</p>
<p><input type="submit" value="Submit" name="submit"></p>
</form>
It all works correctly if i disable the form and write the variable into the script myself ie. $cat_1 = true
Ultimatley what i want is a document with the following output
<?php $cat_1 = true; $man_1 = false; $new_1 = true; $find_1 = false; $info_1 = true; ?>
(true and false values may differ obviously)
Any help is much appreciated!!