[TC] Gaming Forums
Help pleaseeeee :) - Printable Version

+- [TC] Gaming Forums (https://forum.city-driving.co.uk)
+-- Forum: Community Area (/forumdisplay.php?fid=14)
+--- Forum: Off-Topic Chat (/forumdisplay.php?fid=15)
+--- Thread: Help pleaseeeee :) (/showthread.php?tid=298)



Help pleaseeeee :) - Ash - 2011-10-19 15:55

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


RE: Help pleaseeeee :) - Elmo - 2011-10-19 18:51

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

There's also a couple of dropdown box examples at the bottom


RE: Help pleaseeeee :) - Ash - 2011-10-19 18:55

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


RE: Help pleaseeeee :) - Elmo - 2011-10-19 19:06

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


RE: Help pleaseeeee :) - Ash - 2011-10-19 19:08

Ok awesome mate thanks! Smile
Edit: Could you not change the option URL's or something?


RE: Help pleaseeeee :) - Elmo - 2011-10-19 19:21

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



RE: Help pleaseeeee :) - Ash - 2011-10-19 19:24

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?


RE: Help pleaseeeee :) - Elmo - 2011-10-20 19:53

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



RE: Help pleaseeeee :) - Ash - 2011-10-20 20:03

Works VERY well Smile


RE: Help pleaseeeee :) - Crille - 2011-10-21 08:48

I understand nothin