Jump to content

Php variable passing help


mrbrightside

Recommended Posts

Im currently building a site for a university project, and im stuck with something.

basically I have a users page were you can view a users profile. I pass the username to the page and the users details are loaded.

for example.

http://www.mywebsite.com/users/index.php?username=mrbrightside

so that all works. But I want to be a bit more professional with this and somehow hide the variable name. Ive seen it done on other website, but cant work out how or if it is possible to do using PHP. Basically how i want the URL to appear would be:

http://www.mywebsite.com/users/mrbrightside

so the user name is passed, but you dont see the name of the page (index.php) nor the query string (?username=mrbrightside)

is this possible? - if so how?

thanks a million in advance

stuart
Link to comment
Share on other sites

ok well thanks for answering to my post so quickly anyway!

I have played with .htaccess files before on another website i build, but this current one is hosted with godaddy.com, and I got a horrible feeling they dont allow you to mess with that kind of stuff.

I will investigate anyway - thanks
Link to comment
Share on other sites

Two other options for you mrbrightside,

One, code all your variables in form elements and use $_POST['xyz'] to get them.

Two, use sessions to hold your variables and use $_SESSION['xyz'] to get them.

For either one, you'd want some sort of interface where you could set the variable, then store it by your chosen method, and display or whatever.

Two can be tricky if you're unfamiliar with session variables.

Jeff
Link to comment
Share on other sites

THANKYOU 448191

A quick read through the link you suggested and a few attempts later and I got it all working!

godaddy does support mod_rewrites!

It didnt work when I tested if through the full subdomain path:

e.g.

http://beta.myurl.com/users/mrbrightside

but did work through the full url:

http://www.myurl.com/beta/users/mrbrightside

maybe im doing something wrong in the .htaccess file, but at least it works!

thanks again

stuart
Link to comment
Share on other sites

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.