having PHP/javascript create a website based on options picked
I want the user to be able to pick two different variables开发者_如何学Python from a website (from a drop down menu) and hit a button to bring them to a page where files are to download based on the variables picked.
I have the html ready to go.. and i have both menus in an array in php.. i was wondering how to pass both variables through to another site and then have unique content depending on which ones picked..
how do i get php to make it's own site?
Try something like this:
page1.php
<?php
$ar = array('foo', 'bar');
?>
<form action="page2.php" method="post">
<select name="choice">
<?php foreach($ar as $value) { ?>
<option value="<?php echo $value ?>"><?php echo $value ?></option>
<?php } ?>
</select>
<input type="submit" value="go to page2">
</form>
page2.php
<?php
$choice = $_POST['choice']; // sanitize as needed
if( $choice === 'foo' ) {
// do foo choice
}
else if( $choice === 'bar' ) {
// do bar choice
}
?>
Query strings are also ok, just change the form method to GET, and $_POST
to $_GET
.
have you tried using query variables? og perhaps posting the info to the page?
I would suggest using the query like: http://www.yourdomain.com/speciallayoutpage.php?layout=2&colortheme=1
精彩评论