Author |
Session and Validation |
Adrianna
Member
Posts: 3
Location:
Joined: 19.09.11 |
Posted on 20-09-2011 14:24 |
|
|
Hi Folks..
There I have 3 Forms.. 1.php, 2.php, 3.php
Users, get Captcha validation first... if that is "ok", the get redirect to a "choice.php" witch hold 3 links to 1, 2 or 3 (php's).
Question:
Need to pass session to other pages, so.... In order to validate users access to "choice.php, 1.php, 2.php, 3.php"... I need to place a php header, a php script that call auth.php
Here is auth php :
<?php
//Start session
session_start();
//Check whether the session variable "captcha" is present or not
if(!isset($_SESSION['captcha']) || (trim($_SESSION['captcha']) == '')) {
//This works as else statement
header("location: custom_error_page.php");
exit();
}
?>
But no luck at all.. anyone..?
Thanks in advance... lo |
|
Author |
RE: Session and Validation |
Adrianna
Member
Posts: 3
Location:
Joined: 19.09.11 |
Posted on 21-09-2011 13:59 |
|
|
Here is better example... I need auth captcha session to other pages:
index.html
<html>
<body>
<a href="http://my_site.com/example.php">New user ? ..sign up!</a>
</body>
</html>
example.php
<?php
/* ..... Captcha ZDR ..... */
session_start();
?>
<html>
<body>
....
<form name="form1" method="post" action="example_submited.php">
....
</body>
</html>
example_submited.php
<?php
/* ..... Captcha ZDR ..... */
session_start();
?>
<html>
<body>
<?php
// $_SESSION['captcha'] contain true value from captcha image, you can make COMPARISON with string entered from user. EXAMPLE:
include("class/captchaZDR.php");
$capt = new captchaZDR;
if($capt->check_result())
{
include('choice.php');
}
else
{
readfile('error.php');
}
?>
</body>
</html>
choice.php
<?php
require_once('auth.php');
?>
<html>
<body>
<a href="http://my_site.com/geo_class.php">Sign up for Geo Class!</a>
<a href="http://my_site.com/math_class.php">Sign up for Math Class!</a>
<a href="http://my_site.com/english_class.php">Sign up Englis Geo Class!</a>
</body>
</html>
auth.php
<?php
//Start session
session_start();
//Check whether the session variable "captcha" is present or not
if(!isset($_SESSION['captcha']) || (trim($_SESSION['captcha']) == '')) {
//This works as else statement
header("location: custom_error_page.php");
exit();
}
?>
For geo_class.php, math_class.php and english_class.php.... I do have header like choice.php with require_once(auth.php) statement.
Question... what is wrong there?.. I cant pass session.. how do I fixed? |
|
Author |
RE: Session and Validation |
Adrianna
Member
Posts: 3
Location:
Joined: 19.09.11 |
Posted on 23-09-2011 02:30 |
|
|
*BUMP* |
|
Author |
RE: Session and Validation |
webtoolz
Member
Posts: 2
Location:
Joined: 05.01.10 |
Posted on 26-09-2011 08:17 |
|
|
Hello Adrianna,
I think you should change the body of function check_result and change the validation. If the following way. Change of function check_result in file captchaZDR.php start on line 214:
From this:
function check_result(){
if( !isset($_SESSION['captcha']) || $_SESSION['captcha']!=$_REQUEST['capt'] || $_SESSION['captcha']=='BADCODE')
{
$_SESSION['captcha']='BADCODE';
return false;
}
else
{
unset($_SESSION['captcha']);
return true;
}
}
To this:
function check_result(){
if( !isset($_SESSION['captcha']) || $_SESSION['captcha']!=$_REQUEST['capt'] || $_SESSION['captcha']=='BADCODE')
{
$_SESSION['captcha']='BADCODE';
return false;
}
else
{
unset($_SESSION['captcha']);
$_SESSION['captchaValid'] = 'YES';
return true;
}
}
Then use for validation:
auth.php
<?php
//Start session
session_start();
if(!isset($_SESSION['captchaValid']) || ($_SESSION['captchaValid'] != 'YES')) {
header("location: custom_error_page.php");
exit();
}
?>
I hope this will help you.
Best Regards
webtoolz |
|