Jump to content

I REALLY need help with this CAPTCHA


codeboy89

Recommended Posts

I am very new to PHP I am including my form postmessage.php and action post.php snippet, then a snippet showing example use of the captchaexample.php. Please show me how to implement this CAPTCHA, as I am lost and tried several times.

 

postmessage.php

<html>

<head>

</head>

<body>

<center>

<table width=400 border=0 cellspacing=10 cellpadding=0>

<tr>

<td>

 

<?php

 

// Get the file

$file = implode('', file ("post.xml"));

 

print "

<p>

<b>Attention!</b> All html tags will be removed<br>

</p>

<form action=post.php method=post>

<input type=hidden name=post value=yes>

<p>

Heading<br>

<input type=text name=name size=30>

</p>

<p>

Message<br>

<textarea name=message rows=5 cols=50></textarea>

</p>

<p>

<input type=submit value=\"Post Message\">

<input type=reset value=Reset>

</p>

</form>";

 

?>

 

</td>

</tr>

</table>

</center>

</body>

</html>

 

 

post.php

<?php

 

$name=$_POST['name'];

$message=$_POST['message'];

 

// Name and Message required

if (( $name == "") || ( $message == "")) {

print "<p align=center>Please go back to complete all fields!<p>";

}

else {

 

//Get the file

$file_name = "post.xml";

$file_pointer = fopen($file_name, "r+");

$lock = flock($file_pointer, LOCK_EX);

$file_read = fread($file_pointer, filesize($file_name));

 

$date = date ("j M Y");

$post = "\n\n<ponmurt>\n<p><span class=name>$name</span><span class=date> $date</span><br>$message</p>\n</ponmurt>";

 

//Paste the updated info into the file

$post = stripslashes($post);

fwrite($file_pointer, "$post");

fclose($file_pointer);

 

print "<head><meta http-equiv=refresh content=0;URL=index.php></head>";

}

 

?>

 

 

example.php

<?

  if(!session_id()) session_start();

 

  header('Cache-control: private, no-cache, must-revalidate');

  header('Expires: 0');

?>

<html>

<head>

<title>Sec-Code Sample Page</title>

<style> <!--

BODY, P, SPAN, DIV, TABLE, TD, TH, UL, OL, LI {

  font-family: Arial, Helvetica;

  font-size: 14px;

  color: black;

}

--> </style>

</head>

<body marginwidth="10" marginheight="10" topmargin="10" leftmargin="10">

<center>

<?

  if($_POST['name'] && $_POST['subject'] && $_POST['message'] && $_POST['secCode']) {

 

    if($_POST['secCode'] != $_SESSION['secCode']) {

      // wrong security code

      echo '<font color="red"><b>WRONG CODE!</b></font>';

    }

    else {

      // security code is valid; reset it!

      $_SESSION['secCode'] = rand(100000, 999999);

      echo '<b>Thanx!</b>';

    }

?>

    <br><br>

    [<a href=<? echo $_SERVER['PHP_SELF]; ?>"><b>Go Back</b></a>]

<?

  }

  else {

?>

    <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">

    <table border="0" cellspacing="0" cellpadding="4"><tr>

    <td><b>Name:</b></td>

    <td><input type="text" name="name" style="width:250px" value="<? echo $_POST['name']; ?>"></td>

    </tr><tr>

    <td><b>Subject:</b></td>

    <td><input type="text" name="subject" style="width:250px" value="<? echo $_POST['subject']; ?>"></td>

    </tr><tr valign=top>

    <td><b>Message:</b></td>

    <td><textarea name="message" wrap="virtual" style="width:250px; height:50px"><? echo $_POST['message']; ?></textarea></td>

    </tr><tr>

    <td><b>Code:</b></td>

    <td><input type="text" name="secCode" maxlength="6" style="width:50px"> <b>«</b>

    <img src="seccode.php" width="71" height="21" align="absmiddle"></td>

    </tr></table><br>

    <input type="submit" value="Submit">

    </form>

<?

  }

?>

</center>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/181745-i-really-need-help-with-this-captcha/
Share on other sites

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.