Below is the code that I sed when my pages were in ASP to check to see if the user was loged in before opening the page, how would I need to change so that it works with PHP?
Thanks
'===========================VERIFY USER============================
dim userid, username,level
userid = session("userid")
username = session("username")
level = session("level")
if userid = "" THEN
response.redirect("../error.htm")
elseif level >= 0 THEN
Dim dbconn, res
Set dbconn=Server.CreateObject("ADODB.Connection")
dbconn.open("suspension")
Set res = DBConn.Execute("SELECT * FROM members WHERE id = '" & userid & "'")
else
response.redirect("../error.htm")
end if
'==============================END====================================
checking to see if user is loged in?
Moderator: General Moderators
It is really easy in PHP. This is a simple version of how I do it.
You know if a session is set, or a cookie has been set, the username has already been verified.
Code: Select all
if (isset($_SESSIONї'username'] || $_COOKIEї'username'])) {
$logged = 1;
}else{
$logged = 0;
}-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
...
You need to store the IP addresses of people visiting your page, along with the time they visited. Then you can manipulate this data to show that say 5 people have been on your site in the last 5 mins.
If you also have registered users then do the same sort of thing but store the username.
If you also have registered users then do the same sort of thing but store the username.
Note that the OP included code for connecting to the database and checking for a paticular user. I know ASP provided session-like variables and application-wide variables, so I suspect the OP'er was doing those checks for a reason. Therefore the provided PHP code should not be viewed as an appropriate translation.