So I though I had it, after days of not finding what I wanted on google, I wrote a if else line of code for my php index file to redirect the user
if $_SESSION['username'] == "username1";
header("location: page.php")
else
echo "Invalid Login";
However I wasn't out of the woods yet. I learned (I am new to PHP, only been using it for 4 days now) that you can only assign one header since the header is completed before all else.
So then I read a line of code that looked like this, here's my implementation:
header ("locaton: page.php?id=" . $_SESSION['ID']);
So basically, it will route the user with whatever user ID to its corresponding page. So if I am user with ID #1 it will redirect me to the page on my server named page.php?id=1.
Now when signing into my website it shows the browser trying to access page.php?id=1 . So I know its working since the line of code in my PHP file is getting the user ID and putting it into the URL, but the problem I'm facing is that my web server for some reason doesn't respond to .php files with that gibberish at the end.
.php loads fine, but .php?id=1 will return an error "not found on server"
So before I leave you asking some questions about my setup:
Yes, I have renamed my file user.php to user.php?id=1 and the server didn't find it.
Then I changed the extension from .php to .php?id=1 and still no avail.
I am using the latest version of XAMPP with phpmyadmin preinstalled since OS X Lion built in web server doesn't start and I can't get it to no matter all the workarounds on the internet.
If I were to get rid of the header and just make it echo, it would, so I know my database is working fine.
I was using MAMP but it was so bloated? it kept freezing (application, not my mac) and the database wasn't working so I switched to xampp.
So with that all said, anyone know why my server isn't finding my .php?id=1 page?
Thanks for the help!
EDIT
Let me specify that I created an encrypted MD5 Login system with the XAMPP and phpmyadmin database creating a new database and table inside that holds the usernames, ids, and passwords. I am doing this instead of using a simple header location for all users because each user will have their private page or profile instead of a generic users page.
if $_SESSION['username'] == "username1";
header("location: page.php")
else
echo "Invalid Login";
However I wasn't out of the woods yet. I learned (I am new to PHP, only been using it for 4 days now) that you can only assign one header since the header is completed before all else.
So then I read a line of code that looked like this, here's my implementation:
header ("locaton: page.php?id=" . $_SESSION['ID']);
So basically, it will route the user with whatever user ID to its corresponding page. So if I am user with ID #1 it will redirect me to the page on my server named page.php?id=1.
Now when signing into my website it shows the browser trying to access page.php?id=1 . So I know its working since the line of code in my PHP file is getting the user ID and putting it into the URL, but the problem I'm facing is that my web server for some reason doesn't respond to .php files with that gibberish at the end.
.php loads fine, but .php?id=1 will return an error "not found on server"
So before I leave you asking some questions about my setup:
Yes, I have renamed my file user.php to user.php?id=1 and the server didn't find it.
Then I changed the extension from .php to .php?id=1 and still no avail.
I am using the latest version of XAMPP with phpmyadmin preinstalled since OS X Lion built in web server doesn't start and I can't get it to no matter all the workarounds on the internet.
If I were to get rid of the header and just make it echo, it would, so I know my database is working fine.
I was using MAMP but it was so bloated? it kept freezing (application, not my mac) and the database wasn't working so I switched to xampp.
So with that all said, anyone know why my server isn't finding my .php?id=1 page?
Thanks for the help!
EDIT
Let me specify that I created an encrypted MD5 Login system with the XAMPP and phpmyadmin database creating a new database and table inside that holds the usernames, ids, and passwords. I am doing this instead of using a simple header location for all users because each user will have their private page or profile instead of a generic users page.
Last edited: