How to remove X-Y coordinates from form submit url?

Discussion in 'HTML & Website Design' started by Kerosene, May 13, 2009.

  1. #1
    I'm using a custom image for my search submit button, which of course results in a url like: domain.com/?s=banana&x=37&y=11
    Is there any way I can use mod_rewrite or a PHP trick to remove these coordinates?
     
    Kerosene, May 13, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Its possible but you need to post the code here.. what i want to know is will these cordinates going to be static or changes everytime
     
    Bohra, May 16, 2009 IP
  3. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #3
    The coordinates change every time, depending on the location of the mouse when the user clicks the submit button. X and Y are irrelevant to the destination page - they do not need to be passed on.

    Ignore the PHP, that's just WordPress stuff:

    <form id="searchform" method="get" action="<?php bloginfo('home'); ?>"><input type="text" id="searchtext" name="s" size="15" value="<? echo $s; ?>" /><input type="image" src="<?php bloginfo('template_directory'); ?>/images/spacer.gif" value="Search" id="submitimg" /></form>
    Code (markup):
    What I'd like is for:
    domain.com/?s=banana&x=37&y=11
    domain.com/?s=banana&x=27&y=63
    domain.com/?s=banana&x=99&y=22

    etc... to all go to
    domain.com/?s=banana
     
    Kerosene, May 16, 2009 IP
  4. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #4
    Why not use the POST variable instead of the GET ? that way all the stuff will be hidden... or probably make a php code just for processing the data

    Say like

    <?php
    $s = $_GET["s"];
    $x = $_GET["x"];
    $y = $_GET["y"];
    if ($x=="37" && $y=="11")
    header( 'Location: http://www.domain.com/?s='.$s.'') ;
    ?>

    Its better to use POST i guess
     
    Bohra, May 16, 2009 IP
    Kerosene likes this.
  5. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #5
    THANK YOU Bohra!
    Your post definitely set me on the right path! Running it all within Wordpress doesn't make it any easier, but I've got it all working now...

    My search form is now:
    method="get" action="presearch.php"

    Then in presearch.php:
    <?php
    $s = $_GET['s'];
    header( 'Location: http://www.domain.com/?s='.$s.'') ;
    ?>

    Such a simple solution. I'm embarrassed I didn't think of it myself :eek:

    Thank you! :)
    +REP +REP +REP :D
     
    Kerosene, May 16, 2009 IP
  6. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #6
    Great you got it working ;) :D

    Enjoy
     
    Bohra, May 16, 2009 IP