Change script by using dropdown
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 is true";
else include("test.php");
?>
thank you .
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Thanks for the reply,
so i tried this with no luck
page1.php
<FORM name ="form1" method ="post" action ="test2.php">
<Input type = 'Radio' Name ='option' value= 'true'
>ON
<Input type = 'Radio' Name ='option' value= 'false'
>OFF
<P>
<Input type = "Submit" Name = "Submit1" VALUE = "Select a Radio Button">
</FORM>
test2.php
<?php
$a = $_POST['option']; // this will either store true/false
if($a)
{
echo 'a is true';
//print ("A is true");
}else{
include ('test.php');
}
?>
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
if i pick either true or false it show (a is true), then on refresh it includes test.php...
thanks
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
ya sry
so this works untill i refresh the page, once refresh it like resets back to include ('test.php')
page1.php
<form method="post" action="page2.php">
<input type="radio" name="option" value="true">true</option>
<input type="radio" name="option" value="false">false</option>
<input type="submit" name="submit" value="Go!">
page2.php
<?php
$a = $_POST['option']; // this will either store true/false
if($a)
{
echo 'a is true';
//print ("A is true");
}else{
include ('test.php');
}
?>
so what i am tring to get is if option true is selected to only show A is true.
but when false is selected include ('test.php').
hope this makes sense :)
thanks
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
on this same script can one change the variable to = content of a differant page ?
so i would write true or false to index.php
$a = $_POST['option']
with
$a = index.php
<?php
$a = $_POST['option']; // this will either store true/false
if($a)
{
echo 'a is true';
//print ("A is true");
}else{
include ('test.php');
}
?>
thanks so much guys for your help.
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
phorce thanks for that,
still once i refresh the script resets its self.
maybe i need to store/save $_POST['option'] so it will not go back.
maybe in session or something.. im not really sure
thanks
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
thanks phorce
almost now with that script, the session seems to stay and will not include test.php at all.
all i am tryin to do is have one page have an on / off, button/radio/dropdown
then second page show test.php when its on and nothing when its off.
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
cool thanks
so basically im tring
to have 2 files.
page1.php should have my form
page2.php should show test.php unless page1.php is selected to off or false.
thanks so much for your help.
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
hmm weird man all i get is Invalid option on both true and false and test.php never shows up.
TKO
Junior Poster in Training
70 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0