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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.