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);
?>