View Full Version : hi - search script that has a special function!
kn100
06-13-2007, 06:19 PM
Hi, this is my first post, and i hope not to be rude by joining.
For my website, all of the other pages have codes, from 0000 to 9999. i want a search script that if you enter in one of these codes in the search box, it will automaticly take you to that page. A bit like teletext. I cannot reveal too much, dont want others stealing my idea.
Also, if possible, if the user were to enter in "spare car parts" then it would just perform a normal search.
Also, I LOVE DYNAMICDRIVE, BEST CODE SITE EVER.
Thanks,
Kevin
djr33
06-13-2007, 06:36 PM
If you want help with the script, you'll probably need to tell us more. Or keep it a secret and write the script yourself.
From what you describe, that isn't a search function at all.
It's fairly simple, really.
Just type in the number, send it to a PHP script, then redirect to the right page, based on the code.
kn100
06-13-2007, 06:39 PM
Thanks for the speedy reply!:)
also, i dont need help with a script,
i just want one where you enter in a code, and then it takes you to an external website.
The reason being that it is for mobiles and it is quicker.
djr33
06-13-2007, 07:00 PM
<form onSubmit="window.location='http://theother.com/dir/'.this.elements.numfield.value.'.htm'; return false;">
<input type="text" name="numfield">
<input type="submit">
</form>
That uses javascript, though.
to be safe for other browsers, you might want to add PHP to it as well.
Same as above, but add action="nextpage.php" method="get" to the form tag.
On nextpage.php, use the following code:
<?php
header("Location: http://theother.com/dir/".$_GET['numfield'].".htm");
echo "You are being redirected to the next page";
?>
That should work, with a little modification, at least.
Note that there is no error checking in this, so if they enter an incorrect value, they will get a 404 on the redirect. You could, I suppose, use a dropdown menu for this, if that would help the user know what to enter, though it would be awkward with thousands of numbers.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.