3

I have a drop down box from which the user selects a value. I want to post this value to Map.php where it will be used. I currently have my form posting to Map.php which is fine - however, I want to navigate to index.php after the user has made their selection and clicked the button, rather than navigating to Map.php. I have looked for a solution to this, but they all appear to be for situations where you would be visiting the page that the data is posted to...

userInterface.php

<form name="formname" method="post" action="Map.php">
    <div id='userList'>
        <?php
        //get constants for database
        require("database.php");

        // Opens a connection to a MySQL server
        $connection = mysqli_connect ($server, $username, $password);
        $query = "SELECT distinct user FROM route";
        $result = mysqli_query($connection, $query);
            echo '<select name="dropdown" style="width:400px;">';
                $count = 1;
               while($r = mysqli_fetch_assoc($result)){
                echo "<option value =".$count.">".$r['user']."</option>"; 
                $count++;
            }   
            echo '</select>';
            ?>
        <input type="submit" id="button" value="Get Started!" /> 

Map.php

$value = $_POST['dropdown'];
if($value==1){....
fst104
  • 816
  • 1
  • 10
  • 22
  • 1
    You can either do the post asynchronously or use the location header. – frz3993 Sep 30 '15 at 16:51
  • *Sidenote:* From the looks of it, you haven't selected a database to connect to; if that's your full/actual code, nor have you closed your form tag. – Funk Forty Niner Sep 30 '15 at 16:58
  • @Fred-ii- Who knows what `require("database.php");` has in store `;-)` – DirtyBit Sep 30 '15 at 17:11
  • It is not the full code... Database is connected and working, form is closed, and database.php are values to establish my connection which is not shown above. – fst104 Sep 30 '15 at 17:18

1 Answers1

0

Just use header like this :

header('Location: http://www.example.com/');

Based on PHP docs : http://php.net/manual/en/function.header.php

Halvra
  • 285
  • 1
  • 9