[SOLVED] Radio Button Response! :(

This is a discussion on "[SOLVED] Radio Button Response! :(" within the PHP Forum section. This forum, and the thread "[SOLVED] Radio Button Response! :( are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 15th, 2007, 18:41
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down [SOLVED] Radio Button Response! :(

Hey hey.

I dont know whether this should go in html/php so i posted in both (sorry admins :'( )

Riiiiiggghhtt


I was sppooshing around on the net when i found an awsome website with an awsome feature which i want =D


The origonal website is
Code: Select all
http://www.jimmyr.com
located on the index page. The top google search feature!

Right, so I got me the source and edited a bit to suit me (still editing).
However i need help recreating a file which i cant get the source of
Code: Select all
http://www.jimmyr.com/coordinate1.php
As i gather, after selecting the radio button and typing in what you want to search for on google, it posts the info to coordinate1.php then from there it opens a new window with google.com/search....X...F

X is what has been entered in the index page, F the google search command which would vary for each radio box selected.

I have tried endles times recreating it myself, but i can only get it t work when theres only 1 radop button to 1 text and submit button.

Here the source
Code: Select all
http://blizma.co.uk/googleproject/project.txt
I noticed that dude used a different post method.
----------

I need help writting the the .php file where the radio and textbox info is submitted to. I think the project.txt form needs wriritting though for it to work?
Maybe if someone could do that, and write out an example of the response.php? enough so i can cut n past to all of them.

I know it sounds alot, id be SOOO thankfull if someone could do this, i dont know if its against the rules but i would be willing to donate the person or this website. I have had lllooooonnngg hours reading ebooks trying to write this stupid php file with my nooby experience =[

Thank you in advanced!!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 15th, 2007, 21:52
Highly Reputable Member
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

I think you need to use the GET method instead of POST becuase you are sending variables to the browser
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 15th, 2007, 22:34
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Thanks for reply.

As i said i have no idea =D

I know this might be big project thats why i offer donation ONLY IF its not against the rules, which i dont know.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 17th, 2007, 14:47
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

still needing help on this..
thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 17th, 2007, 15:06
Highly Reputable Member
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Miht be worth having a look here

http://code.google.com/apis/ajaxsearch/signup.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 17th, 2007, 16:08
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Okay, this should pretty much emulate what that site is doing... It just save the PHP in a file on your server and then point your form at it and boom! Done.

Cheers,



PHP: Select all

<?php



// No biggie really

// Set up an array with the google query strings 
// Save this PHP file as something.php and then point the form below at it.
$headerSettings = array();

$headerSettings['mp3']            = ' intitle:"index.of" "parent directory" "size" "last modified" "description" [snd] (mp4|mp3|avi|flac|aac|ape|ogg) -inurl:(jsp|php|html|aspx|htm|cf|shtml|lyrics-realm|mp3-collection) -site:.info';

$headerSettings['albums']         = ' site:zshare.net OR site:rapidshare.net OR site:rapidshare.com OR site:megaupload.com OR site:updownloadserver.de OR site:sharebigfile.com OR site:upload.sc OR site:bigfileupload.com OR site:upload2.net';

$headerSettings['torrents']        = ' site:thepiratebay.org OR site:mininova.org OR site:torrentspy.com OR site:isohunt.com';

$headerSettings['free_uni']        = ' site:mit.ols.usu.edu OR site:cnx.ols.usu.edu OR site:ocw.mit.edu OR site:cnx.rice.edu OR site:sofia.fhda.edu OR site:ocw.jhsph.edu OR site:ocw.usu.edu OR site:www.twocw.net OR site:mit.ocw.universia.net OR site:ocw.osaka-u.ac.jp OR site:ocw.kyoto-u.ac.jp OR site:ocw.dmc.keio.ac.jp OR site:www.ocw.titech.ac.jp OR site:ocw.u-tokyo.ac.jp OR site:webcast.berkeley.edu OR site:en.wikibooks.org OR site:free.ed.gov OR site:firstgov.gov ';

$headerSettings['pdf']            = ' filetype:pdf ';

$headerSettings['ringtones']     = ' intitle:"index.of" "parent directory" "size" "last modified" "description" [snd] (mid|midi|imelody|qcp|rtttl|rtx|sckl|ott) -inurl:asp -inurl:htm -inurl:html -inurl:cf -inurl:jsp';

$headerSettings['youTube']        = 'search_type=search_videos&search_sort=video_view_count&search_category=0&search=Search&so=3&start=0&search_query=';

if (isset(
$_POST['searchType']) && isset($headerSettings[$_POST['searchType']))
{
    if (
$_POST['searchType'] == 'youTube') {
        
header ('Location: http://youtube.com/results?' urlencode($headerSettings['searchType'] . $_POST['searchTerm']));
        exit();
    }
    
    
header ('Location: http://www.google.com/search?hl=en&q=' urlencode($_POST['searchTerm'] . $headerSettings['searchType']));
    exit();
    
//PHP all done
}

?>
HTML: Select all
<form name="whatever" action="whateveryounamedthephpfile.php" method="post" target="_blank">
<input type="text" name="searchTerm" value="
" /> <input type="submit" name="submit" value="Search" /><br />
<input type="radio" name="searchType" value="mp3" id="mp3" /><label for="mp3">MP3</label>&nbsp;
<input type="radio" name="searchType" value="albums" id="albums" /><label for="albums">Albums</label>&nbsp;
<input type="radio" name="searchType" value="torrents" id="torrents" /><label for="torrents">torrents</label>&nbsp;
<input type="radio" name="searchType" value="free_uni" id="free_uni" /><label for="free_uni">free_uni</label>&nbsp;
<input type="radio" name="searchType" value="pdf" id="pdf" /><label for="pdf">pdf</label>&nbsp;
<input type="radio" name="searchType" value="ringtones" id="ringtones" /><label for="ringtones">ringtones</label>&nbsp;
<input type="radio" name="searchType" value="youTube" id="youTube" /><label for="youTube">youTube</label>&nbsp;
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Oct 17th, 2007, 17:18
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Omg, you do not know how thankfull i am!!! THANKYOOH!!! =D

here's your work:

Code: Select all
http://www.blizma.co.uk/beta/
I think theres 1 tiny error apparently on line 24 =S
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Oct 17th, 2007, 17:23
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Change this line

if (isset($_POST['searchType']) && isset($headerSettings[$_POST['searchType']))

to

if (isset($_POST['searchType']) && isset($headerSettings[$_POST['searchType']]))

Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Oct 17th, 2007, 17:30
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Ok updated =D

Hmm seems to work but not the commands :'(
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Oct 17th, 2007, 17:42
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Sorry buddy, must be a bit tired.

replace
PHP: Select all



    
if ($_POST['searchType'] == 'youTube') {

        
header ('Location: http://youtube.com/results?' urlencode($headerSettings['searchType'] . $_POST['searchTerm']));

        exit();

    }

    

    
header ('Location: http://www.google.com/search?hl=en&q=' urlencode($_POST['searchTerm'] . $headerSettings['searchType']));

    exit(); 
with

PHP: Select all

    if ($_POST['searchType'] == 'youTube') {

 
        
header ('Location: http://youtube.com/results?' rawurlencode($headerSettings[$_POST['searchType']] . $_POST['searchTerm']));
 
        exit();
 
    }
 
    
 
    
header ('Location: http://www.google.com/search?hl=en&q=' rawurlencode($_POST['searchTerm'] . $headerSettings[$_POST['searchType']]));
 
    exit(); 
Cheers,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)

Last edited by Rakuli; Oct 17th, 2007 at 17:44.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Oct 17th, 2007, 18:07
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Thanks very much, it works now, i updated the link.

THanks soooo much!! =D

1 final question, i would be able to use this on
Code: Select all
blizma.co.uk/find/
if i re-write it using m so called commen sense? =D
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Oct 17th, 2007, 18:12
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

My code's not common sense? LOL,

Yeah, use it wherever you want change it around if you want

Have fun with it..
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Oct 17th, 2007, 21:21
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

Hey again =D

1 question =D

You know how you did the youtube one, how can I make a few more search on other sites? i kept trying keeps coming with error...

Here is what i have done as an example (which is wrong)


Code: Select all
$headerSettings['wiki']           = '';
$headerSettings['youtube']        = 'search_type=search_videos&search_sort=video_view_count&search_category=0&search=Search&so=3&start=0&search_query=';

if (isset($_POST['searchType']) && isset($headerSettings[$_POST['searchType']]))
{
    if ($_POST['searchType'] == 'youTube') {
        header ('Location: http://youtube.com/results?' . rawurlencode($headerSettings['searchType'] . $_POST['searchTerm']));
        exit();
        if ($_POST['searchType'] == 'wiki') {
              header ('Location: http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=' . rawurlencode($headerSettings['searchType'] . $_POST['seachTerm']));
              exit();
          }
    header ('Location: http://www.google.com/search?hl=en&q=' . rawurlencode($_POST['searchTerm'] . $headerSettings[$_POST['searchType']]));
    exit();
}
?>
Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Oct 18th, 2007, 05:05
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

I can't see anythin wrong with that

you could cut the line back to just

header ('Location: http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=' . rawurlencode($headerSettings$_POST['seachTerm']));
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Oct 18th, 2007, 13:38
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Radio Button Response! :(

hey hey,

nope doesnt work.
line 33 is that lin you pasted up there.

Parse error: syntax error, unexpected T_VARIABLE in ......................... test.php on line 33
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Oct 19th, 2007, 07:34
Rakuli's Avatar
SuperMember