Web Tool Bag  
Home · Articles · Downloads · Discussion Forum · Web Links · News Categories · Synonyms DatabaseApril 19 2024 19:39:22
Navigation
Home
Articles
Downloads
Discussion Forum
Web Links
News Categories
Synonyms Database
Search
Users Online
Guests Online: 1
No Members Online

Registered Members: 856
Unactivated Members: 118
Newest Member: lakim
Forum Threads
Newest Threads
Error: Cannot find m...
Uncaught Error: _reg...
Module build failed:...
Installation
mochi script questions
Hottest Threads
Installation [12]
Any questions and... [5]
Captcha picture d... [4]
Integrate with Vi... [4]
Mods: Sucess/Than... [4]
 
Latest Articles
Ubuntu: the vpn conn...
Howto Install HP Pri...
ReactJS progress met...
react-show-more-text
react-collapsible-co...
View Thread
Web Tool Bag | ZDR Scripts- development and maintenance | Captcha ZDR - Questions and answers
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
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Member Poll
Which PHP framework do you preffer?

Symfony

Zend

CodeIgniter

PHP on TRAX

eZ Components

Fusebox

PhpOpenbiz

Prado

QPHP

Seagull

You must login to vote.
Shoutbox
You must login to post a message.

Vince
03/10/2011 18:17
Hi, How to remove Register from Login screen? I don't want them to register and have full access! if you leave register then they should not have any rights until the admin assigns them

webtoolz
26/09/2011 08:28
Please describe your problem with more details. Thank you.

bimmer98
22/11/2010 18:31
Help. There was a problem with the request; error regarding feedbackzdr form program

Custom web software development by Devzone Tech
Copyright © 2024 - www.webtoolbag.com