Solved

Redirect search function to 2 separate pages

Posted on 2014-03-16
3
200 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
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 108

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now