Jump to content

Want to Create an User authentication image


anushka

Recommended Posts

<?php

// ... the login script is up here

//session_start();

?>

<html>

<head>

<title>Basic Login</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body>

<?php

if ($errorMessage != '') {

?>

<p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p>

<?php

}

?>

<form action="" method="post" name="frmLogin" id="frmLogin">

<table width="500" border="1" align="center" cellpadding="2" cellspacing="2">

<tr>

<td width="150">User Id</td>

<td><input name="txtUserId" type="text" id="txtUserId"></td>

</tr>

<tr>

<td width="150">Password</td>

<td><input name="txtPassword" type="password" id="txtPassword"></td>

</tr>

<tr>

<td width="150">Enter Number</td>

<td><input name="txtNumber" type="text" id="txtNumber" value="">

  <img src="randomImage.php"></td>

</tr>

 

<tr>

<td width="150"> </td>

<td><input name="btnLogin" type="submit" id="btnLogin" value="Login"></td>

</tr>

</table>

</form>

</body>

</html>

dis is my  login form named has login.php

randomImage.php

 

<?php

session_start();

 

// generate 5 digit random number

$rand = rand(10000, 99999);

echo hello;

 

// create the hash for the random number and put it in the session

$_SESSION['image_random_value'] = md5($rand);

 

// create the image

$image =imagecreate(60, 30) or die("couldnot create image");

 

// use white as the background image

$bgColor = imagecolorallocate ($image, 255, 255, 255);

 

// the text color is black

$textColor = imagecolorallocate ($image, 0, 0, 0);

 

// write the random number

imagestring ($image, 5, 5, 8, $rand, $textColor);

 

// send several headers to make sure the image is not cached

// taken directly from the PHP Manual

 

// Date in the past

header("Expires: Mon, 26 Jul 2020 05:00:00 GMT");

 

// always modified

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

 

// HTTP/1.1

header("Cache-Control: no-store, no-cache, must-revalidate");

header("Cache-Control: post-check=0, pre-check=0", false);

 

// HTTP/1.0

header("Pragma: no-cache");

 

 

// send the content type header so the image is displayed properly

header('Content-type: image/jpeg');

 

// send the image to the browser

imagejpeg($image);

 

// destroy the image to free up the memory

imagedestroy($image);

?>

 

 

These are the two pages .when i compile  i am not able to display the Random image

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.