•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 422,797 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,387 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1265 | Replies: 21 | Solved
![]() |
•
•
Join Date: Sep 2006
Posts: 89
Reputation:
Rep Power: 3
Solved Threads: 0
Hi this is Scorpion
I have create 5 pages on PHP
and 1 login Page.
Now the issue is that if user didnt login to the Website, then he cannot view those pages and simply he/she must direct to login page if click to other categories of Page.
I have Created a session but it is not doing it so.
Any help will be appreciated with great concern
Regards
Scorpion
I have create 5 pages on PHP
and 1 login Page.
Now the issue is that if user didnt login to the Website, then he cannot view those pages and simply he/she must direct to login page if click to other categories of Page.
I have Created a session but it is not doing it so.
Any help will be appreciated with great concern
Regards
Scorpion
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
when the user logs in, put his username in the session. In all other pages, check if $_SESSION['username'] is set and not equal to null. If its null, then use header function to redirect to the login page.
Eg.
Cheers,
Naveen
Eg.
php Syntax (Toggle Plain Text)
//after user logs in, $_SESSION['username']=$username; // in other pages, if(! isset($_SESSION['username']) || $_SESSION['username']=="")) { //redirect to login page }
Cheers,
Naveen
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Sep 2006
Posts: 89
Reputation:
Rep Power: 3
Solved Threads: 0
Hi this is scorpion
if i want to create my user account
like
Name, loginname, email,password...
let suppose i enter these values to create account in my Signup Form
let suppose i click on button "Create Account"
if ('')
{
then it direct to Welcome user page and and it must be sign in automatically....
}
but
in my Present case what i am dong is that
i give the location but it is automatically directing to Sign in Page.
Infact i start seession in my welcome_user.php
well how to direct it to get login automatically when create an account
not to sign in.
Any help will be higly appreciated
Thanks and Regards
scorpion
if i want to create my user account
like
Name, loginname, email,password...
let suppose i enter these values to create account in my Signup Form
let suppose i click on button "Create Account"
if ('')
{
then it direct to Welcome user page and and it must be sign in automatically....
}
but
in my Present case what i am dong is that
i give the location but it is automatically directing to Sign in Page.
Infact i start seession in my welcome_user.php
well how to direct it to get login automatically when create an account
not to sign in.
Any help will be higly appreciated
Thanks and Regards
scorpion
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
On successful registration, add username to the session. In the next page, check if session is set, if yes, then redirect directly to the page which he gets after successful login. If session is not set, redirect him to login page.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Sep 2006
Posts: 89
Reputation:
Rep Power: 3
Solved Threads: 0
if(isset($_POST['create_user']))
{
$usr_email_chk_avail = $_POST['user_email'];
$usr_nam_chk_avail = $_POST['user_name'];
$usr_pass_chk_avail = $_POST['user_password'];
$sql_chk = "select * from login_session where user_email='$usr_email_chk_avail' AND user_name='$usr_nam_chk_avail' AND user_password='$usr_pass_chk_avail'";
echo $sql_chk;
$result_chk = mysql_query($sql_chk);
$num_rows = mysql_num_rows($result_chk);
if ($num_rows <= 0)
{
echo "<script>alert('Congratulation This User Name: Available for You')</script>";
echo $sql_chk;
echo "<script>window.location='http://localhost/login_sess/welcome_user.php'</script>";
include 'create_user.php';
$_SESSION('u_name') = $usr_nam_chk_avail;
}
this is my code
but it is throwing error
Fatal error: Can't use function return value in write context in C:\xampp\htdocs\login_Sess\sign_up.php on line 100
{
$usr_email_chk_avail = $_POST['user_email'];
$usr_nam_chk_avail = $_POST['user_name'];
$usr_pass_chk_avail = $_POST['user_password'];
$sql_chk = "select * from login_session where user_email='$usr_email_chk_avail' AND user_name='$usr_nam_chk_avail' AND user_password='$usr_pass_chk_avail'";
echo $sql_chk;
$result_chk = mysql_query($sql_chk);
$num_rows = mysql_num_rows($result_chk);
if ($num_rows <= 0)
{
echo "<script>alert('Congratulation This User Name: Available for You')</script>";
echo $sql_chk;
echo "<script>window.location='http://localhost/login_sess/welcome_user.php'</script>";
include 'create_user.php';
$_SESSION('u_name') = $usr_nam_chk_avail;
}
this is my code
but it is throwing error
Fatal error: Can't use function return value in write context in C:\xampp\htdocs\login_Sess\sign_up.php on line 100
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
its not
$_SESSION('u_name') = $usr_nam_chk_avail; But the one I posted above.
$_SESSION('u_name') = $usr_nam_chk_avail; But the one I posted above.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- How to disable Back button of IE when executing welcome.aspx page? (ASP.NET)
- Creating a login page (ASP)
- Please help with login page code behind (ASP.NET)
- ASP.NET Registration Page (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: Parse error: syntax error, unexpected T_VARIABLE
- Next Thread: change row to colum



Linear Mode