Jump to content

How to pass variable through URL and then GET that variable in to a form?


the5thace

Recommended Posts

I'm trying to get a query expansion sort of effect that shows suggestions for misspellings and then lets you click them to input them in to your form. So I have passed a variable through a hyperlink but I can't seem to GET it in to the "value" field

 

 

 

<form method="POST" action='AllinOneMonstaaa.php'>
        <label for="query">Query</label><br/>
        <input name="query" type="text" size="60" maxlength="60" value="<?php echo ($_GET['query']);?>" /><br /><br /> 

Notice the $_GET. I want it to be auto-filled if a user has selected an option in the previous page from the following php file. 

 

 if ($s_count > 1)
    {     
        echo ('<h4>Did you mean?</h4>');
        while ($ss_count <=$s_count)
        {
        echo '<a href = "AllinOneMonstaaa.php?query='.$suggestion[$ss_count].'">'.$suggestion[$ss_count].'</a><br>';
        $ss_count++;
        }
        
    }

Ok, so when the user selects the option, does the url then populate with something like this?

 

AllinOneMonstaaa.php?query=someinfo

 

If so then 

$_GET['query']

 will populate

 

If it is not populating, then can you please explain in a little more detail what you are trying to do?

Hi the5thace,

 

Your code is absolutely fine. I compiled your code and got some very good results. I think the problem you are having is that the variable $suggestion[$ss_count] is not generating some value during the URL creation. 

Please check  what @parkerJ has mentioned. 

 

Does you URL look like AllinOneMonstaaa.php?query=somevaluehere ?

 

Otherwise, please mention the error you are getting

 

Cheers

;D 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.