ok I have a login form that works and checks but I can just pout in the url to go to a specific page inside of the website I am designing and get into it without logging in, how can I remedy this? I have gone through many tutorials and every time I hit the protection script it throws me to the page I want the people not signed in to go to even if i sign in propperly.
GraficRegret
0
Junior Poster
Recommended Answers
Jump to PostActually it's hard to decipher what you wan't although your thread's question is understandable; though too generalize. Can you please provide a snippets of your code, and put what you want to do in bullets? If it's ok for you.
Jump to PostThe problem's in the login function, you don't have any DB resource to reference to when execution the query.
function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = $password; // Particularly in this part $query = mysql_query("SELECT COUNT(user_id) FROM users WHERE userName = '$username' …
Jump to PostHi,
on your function login, you can try setting the session for that username.
for example,
…if(mysql_num_rows($query)== 1){ ## this user exists ## set session for this user session_start(); $_SESSION['thisUser'] = $username; } else{ ## do what you want to do on failed login }
All 11 Replies
gon1387
22
Newbie Poster
GraficRegret
0
Junior Poster
gon1387
22
Newbie Poster
GraficRegret
0
Junior Poster
veedeoo
474
Junior Poster
Featured Poster
GraficRegret
0
Junior Poster
veedeoo
474
Junior Poster
Featured Poster
GraficRegret
0
Junior Poster
GraficRegret
0
Junior Poster
kam735
0
Newbie Poster
GraficRegret
0
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.