Jump to content

PASSING A HIDDEN VARIABLE


daddyb1

Recommended Posts

I  have a menu that i want to be added to every page of  my coding using a hidden variable, but i cannot get it to work. I using this with a few if conditions. the index page should navigate every page. can anyone help?

 

 

I have attached the files to illustrate the coding i have done so far.

 

[attachment deleted by admin]

Link to comment
Share on other sites

-----index page-----

<?php  $state=$_GET["state"];?>

<?php  $page=$_GET["page"];?>

<html><head><title>CONTROLLER</title><?php include("styles.inc"); ?></head>

<body><div style="position:absolute; top: 1px; left: 1px;"><?php  include("dynamicmenu.inc");?></div>

<div style="position:absolute; top:15px; left: 140px;">

  <?php

if ($state == NULL

{  include("default.inc");

} //DEFAULT  PAGE INCL

else if ($state=="1")

{ include("problem1.inc");

if($page=='1' || $page == NULL) {include("problem1.php");}

if( $page=='2') { include ("problem1s2.php"); }

if( $page=='3') { include ("problem13y.php"); }

if( $page=='4') { include ("problem13j.php"); }

}

else if ($state=="2")

{ include("problemm2.inc");

include("problem2.inc");

} //PROBLEM2 PAGE INCLUDE ?>

</div>

</body>

</html>

 

----problem1.php

<?php

echo'

<input type="hidden" name="page" value="1" />

<input type="hidden" name="state" value="1" />';

echo '<form action="index.php?page=2" method="get">

Enter Coupon State:

<select name="coupon"><option></option><option>NJ</option>

<option>NY</option></select>

<input type="submit" value="ENTER"/>

</form>';

?>

----problem1s2

<?php

echo'

<input type="hidden" name="state" value="1" />

<input type="hidden" name="page" value="2" />

';

$coupon=$_GET["coupon"];

if($coupon=="NJ")

{

  echo "<form action='index.php?page=3' method='get'>";

  echo "<input type='hidden' name='days' value='5'/>";

}

else

if($coupon=="NY")

{

  echo "<form action='index.php?page=4' method='get'>";

  echo "<input type='hidden' name='days' value='1'/>";

}

else

{

  echo "<form action='index.php?state=1' method='get'>";

}

 

echo"ENTER ZIPCODE LAST 2-DIGITS : <input type='text' name='code'>";

echo'<input type="submit" value="NEXT STEP"/>

?>

------problem 13y.php

 

<?php

echo'

<input type="hidden" name="state" value="1" />

<input type="hidden" name="page" value="3" />';

$days=$_GET["days"];

$code=$_GET["code"];

$code2=(int)$code%(int)$days;

if($code2<=2) { echo "FINAL OUTPUT:B$days$code2";}

else  { echo "FINAL OUTPUT:D$code2$days";}

echo "<a href='index.php?state=1'>restart</a>";

?>

----problem13j.php

<?php

 

echo'<input type="hidden" name="state" value="1" />

<input type="hidden" name="page" value="4" />

';

 

$days=$_GET["days"];

$code=$_GET["code"];

$code=10%(int)$code;

if($code<=1) { echo "FINAL OUTPUT:A$days$code";}

else  { echo "FINAL OUTPUT:C$code$days";}

echo'<br /><a href="index.php?state=1">restart</a>';

?>

 

Link to comment
Share on other sites

<input type="hidden" name="page" value="1" />

<input type="hidden" name="state" value="1" />

 

<input type="hidden" name="page" value="2" />

<input type="hidden" name="state" value="1" />

 

<input type="hidden" name="page" value="3" />

<input type="hidden" name="state" value="1" />

 

<input type="hidden" name="page" value="4" />

<input type="hidden" name="state" value="1" />

 

i want these to identify each page that will be included in the index page. each page will be added to the index page based on the if conditions. its not working. is there another way to do it?

Link to comment
Share on other sites

i want each page to be included in the index

page when the condition i have written  is met, but i am trying to read each pagee with a unique hidden variable such as :

<input type="hidden" name="state" value="1" /><input type="hidden" name="page" value="1" /> etc but i am not coding it correctly. does this explain what i am trying to do?

Link to comment
Share on other sites

No one has helped you because we're not entirely sure what you're trying to do.  The code snippet you've provided is essentially gibberish.  Suffice it to say that hidden form values won't be read until they're submitted to your script.  Merely include-ing them won't work as your if-conditionals won't 'see' them.

 

Ultimately, given how fundamental form handling and includes are, your best bet is to brush up on PHP basics.  I'm getting the distinct feeling you're trying to run before you can even crawl, and that's the path of disappointment and failure.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.