Page 1 of 1

How to send two data in url on same parameter ?

Posted: Mon Sep 02, 2013 10:57 am
by fhardi
Hi guys,

I'm new out here... :)
I need help to resolve something that I dont know how to do it.

My request is the following :
From a html Form, how to send two data in url on same parameter ?
I meant from the HTML Form, I have one drop down menu where I can select site or anything and a text field

So my question is how to send data from my drop down menu and data from test field ?
As such as :
&q={date from text field} {data from drop down menu}

In below my form :

Code: Select all

<form action="test.php" method="get">

<input type="hidden" name="cx" value="001921177962244596439:oqp21af-c3g" />
<input type="hidden" name="cof" value="FORID:9" />   
<input type="text" name="q" id="cse_search" class="cadr11FR" size="30" value=""/> Dans 
<select name="q">
  <option>Select...</option>
  <option>site:www.slamonline.com</option>
  <option>site:www.dimemag.com</option>
  <option>site:www.ncaa.com</option>
  <option>site:www.nfl.com</option>
  <option>site:www.nbcsports.com</option>
 <option>site:www.cbssports.com</option>
<option>site:espn.go.com</option>
<option>site:www.fiba.com</option>
<option>site:www.nba.com</option>
 <option>site:msn.foxsports.com</option>
 <option>site:www.themarsreel.com</option>
   <option>site:sports.yahoocom</option>
 </select>
 <input type="submit" value="Submit" />
</form>
I m looking for PHP instruction Or Javascript, more with PHP

Here my site test :
http://jeremy.lin.free.fr/test.php

Thank you guys for your help

Re: How to send two data in url on same parameter ?

Posted: Mon Sep 02, 2013 11:04 am
by Celauran
Don't reuse names.

Code: Select all

www.yoursite.com/?a=foo&b=bar

Re: How to send two data in url on same parameter ?

Posted: Mon Sep 02, 2013 11:44 am
by fhardi
Celauran wrote:Don't reuse names.

Code: Select all

www.yoursite.com/?a=foo&b=bar
Hi Celauran,

thnx for your reply but this happenedin form in a form ,I need to send 2 data in same parameter &q=[1] [2]

Because what I want is to search a word on spcific site, and also I use google custum search, and Google required if you want to search only on one site it looks like this :
Example if I search javascript site:http://forums.devnetwork.net on google , only the the word "javascript" will be found in result on http://forums.devnetwork.net
On google url :

Code: Select all

 https://www.google.com/#q=javascript site:http://forums.devnetwork.net
So on my test site it looks like this :

Code: Select all

test.php?cx=001921177962244596439:oqp21af-c3g&cof=FORID:9&q=Jordan&q=site:www.nba.com
And I would like the parameter q= contains Jordan and site:www.nba.com
As such as :

Code: Select all

test.php?cx=001921177962244596439:oqp21af-c3g&cof=FORID:9&q=Jordan site:www.nba.com
Online it looks like this http://jeremy.lin.free.fr/test.php?cx=0 ... ww.nba.com

Thanks again for your help

Re: How to send two data in url on same parameter ?

Posted: Mon Sep 02, 2013 3:40 pm
by Celauran
Oh, I see what you're saying. You want to use a +

Code: Select all

q=Jordan+site:nba.com
You could have figured this out by simply Googling the search string and looking at the resulting URL.

Re: How to send two data in url on same parameter ?

Posted: Tue Sep 03, 2013 3:12 am
by fhardi
Celauran wrote:Oh, I see what you're saying. You want to use a +

Code: Select all

q=Jordan+site:nba.com
You could have figured this out by simply Googling the search string and looking at the resulting URL.
Hi Celauran

Yes similar, I added "+" between Jordan and site:www.nba.com and the result is same...

Could you help me to write an instruction in PHP to set this up ?
I don't know where to start

Thnx

Re: How to send two data in url on same parameter ?

Posted: Tue Sep 03, 2013 9:44 am
by AbraCadaver
You're not going to be able to do this in PHP with a form. You will need JavaScript.

Re: How to send two data in url on same parameter ?

Posted: Tue Sep 03, 2013 9:54 am
by fhardi
AbraCadaver wrote:You're not going to be able to do this in PHP with a form. You will need JavaScript.
Hi AbraCadaver

Oh really I though we can do it in PHP using variable
Could you give me an example ?

Thnx

Re: How to send two data in url on same parameter ?

Posted: Tue Sep 03, 2013 10:54 am
by AbraCadaver
It depends. You either want to pass data from your form and receive it somewhere, which we can do, or you want the URL to look a certain way. Must the URL look like that or what?

Re: How to send two data in url on same parameter ?

Posted: Tue Sep 03, 2013 11:45 am
by fhardi
Yes I want to pass data from the form and the URL have to look like this way :

Code: Select all

test.php?cx=001921177962244596439:oqp21af-c3g&cof=FORID:9&q=Jordan+site:www.nba.com