Jump to content

Recommended Posts

Hi there, im new to this forum and preaty mutch new to php.. :) so i hope you guys can help me out here :)

 

I wana make a simple page on my website, with a imput form (text area) where client can imput a text, a password for example, and based on that password, they will be redirected to their specific client page.

 

Like here... u go to www.mysite.com/client, here u enter the imput password then will redirect you to www.mysite.com/client/clientname

 

Can this be done with php?

 

Thanks a lot and hope i explained right.

 

Have a nice day and realy hope someone can help me here.

 

Cipri

Link to comment
https://forums.phpfreaks.com/topic/270047-redirect-based-on-form-imput/
Share on other sites

thanks a lot ExtremeGaming, this is the .php file that i have to add in the form? as the action file? sry im realy new to it and trying to understand.

 

I made a client page with this in it

 

 

<div align="center">

<form action="redirect.php" method="get" name="input">Username: <input type="text" name="user" /><input type="submit" value="Trimite" /></form>

</div>

 

the code that you gave my, i need to put it inside the redirect.php file if im right.

 

after that this should work? and can i add another "if" for another client, and maybe a "else" if the imput is wrong?

 

realy appreciate your help, thanks a lot.

Cipri

ExtremeGaming: I would not use htmlentities () (nor htmlspecialchars ()) there, seeing as you're not sending the variable's content to the browser. Instead you've made it quite impossible to match the "password", if it contains a character that would be encoded by the function.

 

Cipri: The "action" file can be the same file as the one that's displaying the form, if you set the action of the form to be empty the browser will post the data back to the current URL. Just remember to parse all PHP at the top of the page, before any (and all) HTML code is sent to the browser.

There are lots of examples on how to make a proper (and secure) form with HTML and PHP, and a search of the forum will bring you lots and lots of examples. I recommend looking at the posts made by the people with badges, or some of my own, for some proper examples. ;)

 

The "Header errors" thread, which is stickied at the top of this section, is also a very good read.

Edited by Christian F.

Thanks a lot Christian F. for your time and your reply, other problem thats on my mind atm, is that i forgot to mention i'm using a wordpress based website, and im creating a page inside wordpress where i wana put this script. Is there a probem with wp interpretaiting the php code inside the page? thanks a lot for your guide, i will take a look over them.

It shouldn't be a problem, no, but I can't give you any guarantees. Don't know how Wordpress handles its output, and thus it may have sent something to the browser before running your code. If it has, your header calls will fail.

You'll find out soon enough though, once you test it. :P

 

You're welcome, btw. Glad I could help. :)

ExtremeGaming: I would not use htmlentities () (nor htmlspecialchars ()) there, seeing as you're not sending the variable's content to the browser. Instead you've made it quite impossible to match the "password", if it contains a character that would be encoded by the function.

 

The point of htmlentities was if they were to display anything that was input. But now that you mention it..my bad :P

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.