| | |
security using cookies/session variables
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
hey guys.
i hav this page (a.php), where i ask te user for his username and password. I match these with static values, and upon succesful matching, i redirect the user to b.php.
my prob-
what if somebody, instead of going thru the normal procedure (from a.php to b.php after verification), directly types in the url for b.php into the address bar???
will that not SHATTER my security??
how can i implement security so that if some1 has not signed in (on a.php) and directly enters the url of b.php, he is
1. sent back to (a.php)
or
2. nothing is displayed on b.php
pls. help
thanks a lot.
i hav this page (a.php), where i ask te user for his username and password. I match these with static values, and upon succesful matching, i redirect the user to b.php.
my prob-
what if somebody, instead of going thru the normal procedure (from a.php to b.php after verification), directly types in the url for b.php into the address bar???
will that not SHATTER my security??
how can i implement security so that if some1 has not signed in (on a.php) and directly enters the url of b.php, he is
1. sent back to (a.php)
or
2. nothing is displayed on b.php
pls. help
thanks a lot.
You just write small logic in one page called login_check.php...
and you must include that file in every page where ever you want security to your page:
like:
In login_check.php:
and you must include that file in every page where ever you want security to your page:
like:
php Syntax (Toggle Plain Text)
<? include("login_check.php"); ?>
In login_check.php:
php Syntax (Toggle Plain Text)
<? session_start(); if(empty($_SESSION['user_name'])) { header('location:index.php'); } ?>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
hi.
thx 4 d reply.
i guess u dint get my equirement totally.
on any page, i want the user to ba able to view the page contents only if
1. he has entered his username AND password
2. both are found to match the actual values
in case either is not true, i redirect him to the login page.
will ur solution help me get this?
pls suggest.
thx 4 d reply.
i guess u dint get my equirement totally.
on any page, i want the user to ba able to view the page contents only if
1. he has entered his username AND password
2. both are found to match the actual values
in case either is not true, i redirect him to the login page.
will ur solution help me get this?
pls suggest.
And tel me where you are going to compare your username and password...
I think that is from database...
tel me...
here is the code for redirecting if username and password are correct...
I think that is from database...
tel me...
here is the code for redirecting if username and password are correct...
php Syntax (Toggle Plain Text)
<? session_start(); include('functions.php'); if($_SERVER['REQUEST_METHOD']=="POST"){ $qer="select * from table where username='".$_POST['username']."' and password='".$_POST['password']."'"; $res=mysql_query($qer); $num=mysql_num_rows($res); if($num==0) { echo'<script language="javascript">window.location.href="anotherpage.php";</script>'; } else if($num==1) { session_unregister("user_name"); session_register("user_name"); $_SESSION['user_name']=$_POST['username']; echo'<script language="javascript">window.location.href="welcome.php";</script>'; } } ?>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
![]() |
Similar Threads
- Do You Know Sessions! HELP PLEASE! (PHP)
- Inserting array into cookie (PHP)
- Zend PHP Certification (PHP)
Other Threads in the PHP Forum
- Previous Thread: how can i fix may website data base??????????????
- Next Thread: dynamic form generation in PHP
Views: 1187 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio random recursion regex remote script search select seo server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web webdesign xml youtube






