PHP Classes

Session

Recommend this page to a friend!

      Simple Image Captcha Class  >  All threads  >  Session  >  (Un) Subscribe thread alerts  
Subject:Session
Summary:Session
Messages:3
Author:Jeremy Wauters
Date:2011-12-03 11:39:07
Update:2012-03-26 04:35:48
 

 


  1. Session   Reply   Report abuse  
Picture of Jeremy Wauters Jeremy Wauters - 2011-12-03 11:39:08
var_dump($_SESSION) returns NULL.

Can you help and provide us a show form example?

  2. Re: Session   Reply   Report abuse  
Picture of Jose Johnson Pallikkathyil Jose Johnson Pallikkathyil - 2012-03-26 04:20:04 - In reply to message 1 from Jeremy Wauters
Simply call this file imagecaptcha.php as source of an image tag
eg: <img src=imagecaptcha.php?code=2422 /> parameter code is optional

  3. Re: Session - Sample code   Reply   Report abuse  
Picture of Jose Johnson Pallikkathyil Jose Johnson Pallikkathyil - 2012-03-26 04:35:48 - In reply to message 2 from Jose Johnson Pallikkathyil
Sample code - - simple form with image captcha implementation.
Put the image cpatcha file (imagecaptcha.php) in same folder as this file

<?php
session_start();
$name="";
$age="";
$msg="";

if( $_POST['submit'] ){

$name=$_POST['txtname'];
$age=$_POST['txtage'];

if( trim($_POST['txtsecurity']) == trim( $_SESSION['security_code']) ){

$msg="Thanks, Your form is submitted";
}else{
//invalid security code
$msg="Sorry Security Code that you entered is incorrect.";
}

}

?>

<form action="" method="post">

<?php echo($msg); ?><br><br>

Enter Name : <input type=text name=txtname value="<?php echo($name) ?>" /><br>
Enter Age : <input type=text name=txtage <?php echo($age) ?> /><br>
Enter Security Code : <br>
<img src="imagecaptcha.php" /> : <input type=text name=txtsecurity /><br><br>
<input type=submit name=submit />
</form>