[TC] Gaming Forums

Full Version: Help pleaseeeee :)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im currently trying to create a html/php page for my own personal homepage.

I want (And have done before, just cant remember how lol), a text box, and a drop down menu. I want the drop down menu to choose where exactly to search, if that makes sense.

So i can have like Google/Yahoo/Bing etc, so i type a text phrase, select where i want it to search, then hit submit.

Any help would be gratefully appreciated! Smile

Thanks

Ash
http://www.w3schools.com/html/html_forms.asp

There's also a couple of dropdown box examples at the bottom
Yehh ive seen that page elmoish, thanks anyway Smile

What i need is a text box though, then a drop down menu, with each of those values to have a html code into it. For example like our URS, have the URL of it, add "file.php?username=" then add the value from the text box into the end of it? For example if i wrote my name, it would show file.php?username=racerash3.

Is it possible? Smile

Thanks

Ash
Code:
<form name="input" action="html_form_action.asp" method="get">
Username: <input type="text" name="user" />
<input type="submit" value="Submit" />
</form>
Entering "some text" into the text box, then pressing submit will send you to:
html_form_action.asp?user="some text"

if you have more than one control within the form tags, it'll send a value for each control.

So, with this code:
Code:
<form name="input" action="dostuff.php" method="get">
Search: <input type="text" name="search_text" />
<select name="search_engine">
<option value="google">Google</option>
<option value="bing">Bing</option>
<option value="wolfram">Wolfram Alpha</option>
</select>
<input type="submit" value="Go" />
</form>

I enter "City Driving" in the text box and select Google on the dropdown, pressing the Go button will do:
dostuff.php?search_text=City%20Driving&search_engine=google

dostuff.php would need to be able to do something with the values it gets. I'll have a quick look how
Ok awesome mate thanks! Smile
Edit: Could you not change the option URL's or something?
Something like this *might* work: (untested)

dostuff.php:
PHP Code:
<?php
$engine 
$_GET["search_engine"];
$text $_GET["search_text"];
switch (
$engine)
{
    case 
"google":
        
$url "http://whatever/" $text;
    (
insert other engines)
}
header("Location: " $url);
exit;
?>
Na doesnt work im afraid Sad I did come up with something purely upon HTML at one point but i cannot remember to save my life Sad Thanks for trying tthough mate! Smile
Would it be possible to get the form's action to be a php variable?
If anyone else is interested, this works:

some html page
PHP Code:
<form name="input" action="dostuff.php" method="get">
Search: <input type="text" name="search_text" />
<
select name="search_engine">
<
option value="google">Google</option>
<
option value="wolfram">Wolfram Alpha</option>
</
select>
<
input type="submit" value="Go" />
</
form

dostuff.php
PHP Code:
<?php
$engine 
$_GET["search_page"];
$text $_GET["search_text"];
switch (
$engine)
{
    case 
"google":
        
$url "Location: www.google.co.uk/#q=" $text;
        break;
    case 
"wolfram":
        
$url "Location: http://www.wolframalpha.com/input/?i=" $text;
        break;
    default:
        echo 
"Error";
        exit;
}
header($url);
exit;
?>
Works VERY well Smile
I understand nothin
Reference URL's