If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

HTML Enter Sub-directory Text Box?

Hello!

I am trying to code a text box so that the user can enter a subdirectory (www.example.com/subdirectory), but only the subdirectory, then press a "Go" button, and they will be taken to the subdirectory.

That’s nothing HTML alone can do, you need a server side processing script and you can enhance this with JavaScript. HTML is only responsible for the existence of the form and input field. The rest is up to the script. I’m moving this over to the PHP forum.

They've used javascript, which I personally wouldn't have used. I know a little javascript and would consider changing the button type input to a submit type, and adding the onSubmit event with the function call.

But, I'm not in a position to test that. So, what I would do is get rid of the relevant javascript and instead, have a script called subdir.php and change the form to this:

That will redirect the user to the subdir they entered - whether they pressed enter or clicked the button. Using PHP allows for expansion and a more secure environment to navigate folders in my opinion.

If they enter the wrong account number (lets say they enter "jsmith", jsmith is not one of the account numbers defined), the error popup opens just fine (explaining that they need to correct their account number), but, they are still progressed onto the page www.example.com/jsmith.html.

In the redirect page, you'll have to add the user check. If you're checking users with javascript, you shouldn't. Javascript is user side executed, meaning they can track and see everything that's executed. If you use the PHP to check the users, they can't see it as it's server side - more secure.