hello, im tyring to change script from another page. i would like to change (a > true) to false and back if need be. As a dropdown or radio selection, maybe using variables but everything i have tried i have no luck. <?php if (a > true ) print "a…
Sorry to butt in here, but wouldn't a checkbox be more appropriate for a true/false? Perhaps not, depending on the use case. If you cast the post data as boolean, you get the true/false:
<?php
if($_POST){
$option = (bool) $_POST['option'];
if($option){
header("Location: index.php");
}
}?>
<form method="post">
<input type="radio" name="option" value="1" checked="checked">True</option>
<input type="radio" name="option" value="0">False</option>
<input type="submit" name="submit" value="Go!">
</form>
diafol
Keep Smiling
10,662 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,513
Skill Endorsements: 57
thanks
still on refresh returns to false..
maybe us session then make false Destroy the session ? just a thought...
<?php
$option = $_POST['option'];
if(!isset($option))
{
echo 'You have not submitted an option';
}
switch($option)
{
case 0:
// FALSE
echo 'This is false';
break;
case 1:
// TRUE
// re-direct to link 1;
$new_link = "test.php";
echo include 'test.php';
break;
default:
echo 'Invalid option';
break;
}
?>
<form method="post">
<input type="radio" name="option" value="1">True</option>
<input type="radio" name="option" value="0">False</option>
<input type="submit" name="submit" value="Go!">
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
By the way, the html I copied was wrong:
<form method="post">
<input type="radio" name="option" value="1" checked="checked">True</option>
<input type="radio" name="option" value="0">False</option>
<input type="submit" name="submit" value="Go!">
</form>
Should be:
<form method="post">
<input type="radio" id="optrue" name="option" value="1" checked="checked" /><label for="optrue">True</label>
<input type="radio" id="opfalse" name="option" value="0" /><label for="opfalse">False</label>
<input type="submit" name="submit" value="Go!">
</form>
@TKO
With regard to PMs, unless it's a personal one, please post all relevant info to the forum as this will help other users with a similar problem.
diafol
Keep Smiling
10,662 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,513
Skill Endorsements: 57
This is the reason why questions of this nature should be put to the forum as opposed to PM. This is related to the problem. WHen he mentioned 'refresh' I assumed he meant 'why isn't the form storing my data'.
The best way to my mind would be a session variable. You could use cookies of course. I find cookies a little fiddly and I tend not to use them very much anymore - especially following the ridiculous cookie legislation - not that that is relevant here.
Anyhow, seeing as TKO sent the PM to you, you should answer him. If he decides to post to the forum, it's open season. :)
diafol
Keep Smiling
10,662 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,513
Skill Endorsements: 57
the only reason pm was sent was for link to file.
no harm intended
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
diafol
Keep Smiling
10,662 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,513
Skill Endorsements: 57
This seems to be way to much trouble so i have decided to go a differant direction on the script.
I just made a script that will fwrite an include every time i hit "on"
and an "off" button that will erase only the content of the file.
Its a total of 5 files but i works.
THANK YOU phorce, diafol and Javvy for your PATIENCE and HELP.
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Ok, mark as solved - if it is.
diafol
Keep Smiling
10,662 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,513
Skill Endorsements: 57
Question Answered as of 8 Months Ago by
phorce,
diafol
and
Javvy TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0