Solved

Redirect search function to 2 separate pages

Posted on 2014-03-16
3
211 Views
Last Modified: 2014-03-16
I'm trying to set up a search function for a property website where you search for either 'Buy' or "Let'

If you click on Buy I want to redirect to uksearch.php  and if you click let you go to uksearchlet.php

I can't figure out how to redirect to separate page depending on the button clicked, hope someone else does!

The info from the hidden info buttons needs to be sent over in the URL.

Here's the code i'm using at the moment which goes the same page regardless of which button you click


   <form name="form1" method="get" action="uksearch.php">
    
    
      <div class="searchbut">      <input type="submit" name="saleorRent" id="button" value="Buy"  style="width: 60px; height: 54px; border: 0px; font-family: Georgia, Times, serif; font-size: 25px; outline: 0px; padding: 0px;background: url(images/search-rent.jpg) no-repeat; cursor: pointer;">
      
      
      
      <input type="submit" name="saleorRent" id="button" value="Let"  style="width: 60px; height: 54px; border: 0px; font-family: Georgia, Times, serif; font-size: 25px; outline: 0px; padding: 0px;background: url(images/search-rent.jpg) no-repeat; cursor: pointer;"></div>
      <input name="area" type="text" class="searchinput" id="area">
     
     
      
      <input name="intsearch" type="hidden" id="intsearch" value="250">
      <input name="max" type="hidden" id="max" value="99999999999999">
      <input name="intsearch" type="hidden" id="intsearch" value="GBR">
    </form>

Open in new window

0
Comment
Question by:BrighteyesDesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39933056
   <form name="form1" method="get" action="uksearch.php">
    
    
      <div class="searchbut">      
<input type="submit" name="saleorRent" id="button" value="Buy"  style="width: 60px; height: 54px; border: 0px; font-family: Georgia, Times, serif; font-size: 25px; outline: 0px; padding: 0px;background: url(images/search-rent.jpg) no-repeat; cursor: pointer;">
      
      
      
      <input type="submit" name="saleorRent" id="button" value="Let"  onclick="javascript:form1.action='uksearchlet.php'" style="width: 60px; height: 54px; border: 0px; font-family: Georgia, Times, serif; font-size: 25px; outline: 0px; padding: 0px;background: url(images/search-rent.jpg) no-repeat; cursor: pointer;"></div>
      <input name="area" type="text" class="searchinput" id="area">
     
     
      
      <input name="intsearch" type="hidden" id="intsearch" value="250">
      <input name="max" type="hidden" id="max" value="99999999999999">
      <input name="intsearch" type="hidden" id="intsearch" value="GBR">
    </form> 

Open in new window

0
 

Author Comment

by:BrighteyesDesign
ID: 39933066
You're a superstar, cheers for that
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39933085
A little bit of theory...
http://php.net/manual/en/tutorial.forms.php

The action= attribute of the form tag determines what URL will be requested when the form is submitted.  You can only submit a form to one URL.  But that one URL can call a script that does lots of interesting things.

For example, the action script could look at the value of the submit control and decide whether to transfer control to a Buy or Let script.  Perhaps this transfer of control could happen via a require() statement.  You can have any number of submit control buttons - as many as you would like - and the value associated with the submit control is the same as any value associated with a text input control.

Please post back if you have any questions -- it's a little involved to set up an example but I'll be willing to do so if you need an example.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question