Jump to content

jonwish

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by jonwish

  1. 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.

  2. 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);
    ?>
    
    
×
×
  • 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.