PHP Cookie help
My DB table having column username and password.
<form id="form1" name="form1" method="post" action="myactionfile.php">
<input name="username" type="text" id="username" />
<input name="password" type="password" id="password" />
I want to apply checking on all pages for username and password.
if you enter correct username and password, you will be able to see entire page otherwise NOT. I want to do it using cookies and sessions.
Thanks in advance
When user submit your form, you should check if username/password combination is correct and if so, you can set username or userid into session.
Then you can check on every page which requires user to be logged it, if that element is set.
You can for example build a little function for that:
Then on each page which requires user to be logged in, you should check
I hope this helps.. Of course you have to start the session with session_start() on each page, or better to start it in a single file which will get included in all others where you need to use sessions.
//continue with a page
okay. but how to store value into $_SESSION["username"])) ?
$_SESSION["username"] = $username;