Form Input Box with Redirect to URL -...

User 1959472 Photo


Registered User
7 posts

Greetings to All, New guy here looking for a little assistance.

Please visit my website (http://www.justvideod.net) and if you look in the top right corner you will see what I'm trying to do. I want to add a single input box with a submit button.

When a visitor enters a number in the input box, I want to append that number to my URL and redirect them to the appropriate page.

For example, www.justvideod.net/branded/497710. I want the visitor to be able to enter their tour MLS number (497710 in this example) and after pressing Submit be redirected to that page.

Any help or suggestions on how to do this is greatly appreciated!

User 414501 Photo


Registered User
564 posts

There is a script called "Key Redirection" which allows you to do that:

http://www.hotscripts.com/listing/key-redirection/#

This script is a redirection program that uses a list of key / url pairs to redirect
users based on the "key" they enter into a form field. There is an administration area which allows you to add new key / url values and to edit or delete existing keys, as well as to view and delete the log file.


I think you could also do this pretty easily with a PHP script. Ask these guys:

http://www.phpfreaks.com/forums/

Chad Spillars
http://www.DisneySubmarines.com
Chad Spillars
"Look I finally made myself a signature!"
User 133269 Photo


Registered User
2,900 posts

yep - easy with php...

send your form to a php page that reads the form settings and redirects to a page...

use the "post" method on your form

get the data on the php page with..
$page = $_POST['formfieldname'];

a few ifs to check the setting and set the page name

then a header() to the page you want...
Have fun
~ Fe Pixie ~
User 1959472 Photo


Registered User
7 posts

Thanks for the quick replies but I'm not that technical...I added some simple code to my page:

<form method='get' action='http://www.justvideod.net/branded/'>
<input type='hidden' name='' value=''>
<input type='text' name='id'>
<input type='submit'>
</form>

This almost works! LOL! But I can't get rid of the ?id=

The resulting url is www.justvideod.net/branded/?id=497710

and I just want www.justvideod.net/branded/497710

User 133269 Photo


Registered User
2,900 posts

Yep - its in the URL because you're using a GET method instead of a POST to send the data along from the form to the next page...

Its then expecting the www.justvideod.net/branded/ page to pick up the info from the url and do something with it... You'll need a bit of php to do that!! :D
Have fun
~ Fe Pixie ~
User 1959472 Photo


Registered User
7 posts

Thanks Fe, any help with the PhP? I went to phpfreaks.com but they haven't replied either....
User 133269 Photo


Registered User
2,900 posts

hmm - you want me to write it for you?

try this....

the form

<form method='post' action='forwarder.php'>
<input type='text' name='id'>
<input type='submit'>
</form>


make a page called forwarder.php and put this in it
<?php
$id = $_POST['id'];
header("Location: /branded/$id");
?>

make sure there are no spare blank lines in that file or it wont go...

should be all you need :)

Have fun
~ Fe Pixie ~
User 1959472 Photo


Registered User
7 posts

Fe, Thank you! Thank you! Thank you! That works like a Champ! I love it! But....there's always a but....:)....I would like to open the new page in a new browser. Can I do that?
User 133269 Photo


Registered User
2,900 posts

Not without a heap more messing about - the header() function dont have any setting for it so you'd have to mess about with javascript or something that can control the browser (php is server side not client side)...

The easiest thing to do would be to have a "open this page in a new window" button once you got there for the user to click if they wanted to...
Have fun
~ Fe Pixie ~
User 414501 Photo


Registered User
564 posts

Daniel,

I posted a link to a free software called key redirection towards the beginning of this post. Why don't you see if that software would allow you specify the page to open in a new browser?
Chad Spillars
"Look I finally made myself a signature!"

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.