473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Php login Advanced Validations

If a user wants to go to profile.php and I assumed that the user is not logged in.
Now i want to redirect the user to login.php and in the login.php will now echo something like YOU MUST LOGIN TO VIEW THIS PAGE and after the user loged in will take the user to the profile.php which the user requested

How will i do that stuff and and also after echoing YOU MUST LOGIN TO VIEW THIS PAGE I will want the echoed content to disappear and show only once so that there will be room to echo login errors.
Can someone Help Thanks
Jul 31 '15 #1
2 2164
Dormilich
8,658 Expert Mod 8TB
this is usually done using sessions. you check in the session if the user’s state is loggen in, and if not you redirect him to the login page.
Aug 1 '15 #2
You can check with session. if the require session is not set on the profile page directly redirect him to login page otherwise if you want to keep him on the profile page, then you can display message there.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(!isset($_SESSION['user_id']))
  3. {
  4. echo "You must have to login first.<a href='login.php'>click here to login</a>";
  5. }
  6. else
  7. {
  8. // code your profile page.
  9. }
  10.  
  11. ?>
  12.  
Sep 2 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michael J. Wendell | last post by:
Hello, I am trying to debug an issue with sessions in my ASP 3.0 web application, which runs fine on WIN2K Pro and WINXP Pro, yet fails to function correctly on WIN2K Advanced Server. My actual...
0
by: Sharath | last post by:
Quality Globe is Glad to Offer you the Fast Track course on Automation, QTP Basics and Advanced, and Quality Center Starting Date: June 4th, 2007 Timings: 10 AM to 3:30 PM Duration: 50 Hours ...
1
by: jsd219 | last post by:
I have a fairly simple login in script and I need to make it have two levels of access not one. can anyone help me with this? The script is below: <?php // we must never forget to start the...
10
by: priyakollu | last post by:
hi guyz! please help me in sorting out error as im unable to find it... my requirement is there will be userid field and password field and "login" button after clicking button certain validations...
3
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it...
2
by: swethak | last post by:
hi , i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my...
5
by: makaman | last post by:
Heys guys, i really need help bad. i'm making a program, and i only want registered ppl to use it, but i'm having lots of problems. i want to make a advanced login system, so that the username and...
8
amit sabal
by: amit sabal | last post by:
<?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array();
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.