jonwish
-
Posts
5 -
Joined
-
Last visited
Posts posted by jonwish
-
-
Thanks for the reply. I have added the alterations as you mentioned to secure the data but I think maybe I have not explained myself properly (my fault).
The dropdown populates okay and if I echo $pagelink it shows the correct link but when I add $pagelink to the header location it only allows the first item from the db to link okay, the rest just go to the homepage with http://www.xxxxxxxx/index.php
I am completely stuck with this as it is echoing the results exactly as it should.
-
Sorry. I don't understand.
If I echo $pagelink I get the post variable shwoing okay?
Appologies, im a bit rusty with all this.
Thanks
-
Hi, Thanks for the fast response. I have added the . to concatenate but it is still doing the same thing (only first option works, others just go to index page)
-
Hi, My first post so please excuse if im ake any mistakes.
I have a drop down that I am getting a post variable from with i am then trying to append an URL with.
It works but only for the first option.
Any help much appreciated.
When I echo the $pagelink it shows the correct value but when I add it to the header location it just goes to the homepage of the site (except the first option)!
My index.php:
<?php // connect to db mysql_connect ("xxxxxx", "xxxxx","") or die (mysql_error()); mysql_select_db ("xxxxxx"); //query $sql = mysql_query('SELECT product_id, name FROM CubeCart_inventory'); $models = array(); while ($row = mysql_fetch_array($sql)){ $models[] = $row; } ?> <form action="config.php" method="POST"> <select name="battery"> <?php foreach ($models as $model) { ?> <option value="<?php echo $model['name']?>"><?php echo $model['name']?></option> <?php } ?> </select> <input type="submit" name="submit" value="Submit" /> </form>
my config.php:
<?php //var_dump($_REQUEST); $name = $_POST['battery']; $pagelink = str_replace(" ","-",$name); $pagelink = strtolower($pagelink); $pagelink = $pagelink.".html"; header ('Location: http://localhost/carrotcycles/test-category/'$pagelink); ?>
passing variable to url
in PHP Coding Help
Posted
The drop down links to an ecommerce site.
Basically: there is a dropdown with a certain categories products. Once a product is selected it would take you to that product page.