Jump to content

Need help with random generation of numbers


Novar

Recommended Posts

This deals with both html/php but anyways

I have forms.. Forms that are easy to be spammed

http://novar.82ndid.com/index2.html ex so far

How would i go about adding in a security so the user needs to type in a random generated number to go to the next page which is mail.php -> then goes to thanks.html

It would deal with both index2.html and mail.php I need alot of help, most sites dont help me I attempt to find.

Here is both my code for index2.html and mail.php Could someone tweak it so it would or post how ?

[code]
<title>82nd Infantry Division Recruitment Application</title>
<form enctype="multipart/form-data" method="POST" action="http://www.novar.82ndid.com/mail.php">
<img src="image.jpg" />
<br>

<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Forms with an asterisk * are required!</b>

<table cellspacing="10" cellpadding="10" border="0">
<tr>
<td valign="top">
<b>Name:*</b>
</td>
<td valign="top">
<input type="text" name="name" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Email Address:*</b>
</td>
<td valign="top">
<input type="text" name="email" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Age:*</b>
</td>
<td valign="top">
<input type="text" name="age" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Where are you from?*</b>
</td>
<td valign="top">
<input type="text" name="location" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Game you are applying for*</b>
</td>
<td valign="top">
<input type="text" name="game" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>In-game specialization?</b>
</td>
<td valign="top">
<input type="text" name="specialization" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Member Recommendation? If yes, who?.*</b>
</td>
<td valign="top">
<input type="text" name="recommendation" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Xfire (Download it at <A HREF="http://www.xfire.com">XFire.com</A>)*</b>
</td>
<td valign="top">
<input type="text" name="xfire" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>AIM/MSN S/N "Specify which client"*</b>
</td>
<td valign="top">
<input type="text" name="aim" size="40" value="">
</td>
</tr><tr>
<td valign="top">
<b>Internet Speed</b>
</td>
<td valign="top">
<input type="text" name="internet" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Past clans/guilds</b>
</td>
<td valign="top">
<input type="text" name="pastclans" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Can you donate?*</b>
</td>
<td valign="top">
<input type="text" name="donate" size="40" value="">
</td>
</tr>
<tr>
<td valign="top">
<b>Comments</b>
</td>
<td valign="top">
<TEXTAREA Name="comments" rows="4" cols="30"></TEXTAREA>
</td>
</tr>

<tr>
<td valign="top">
<b>Do you accept the code of conduct?<A HREF="http://www.novar.82ndid.com/coc.html" TARGET="_blank"><br>View it here</a>*opens new window**</b>
</td>
<td valign="top">
<TEXTAREA Name="coc" cols="30"></TEXTAREA>
</td>
</tr>



<tr>
<td colspan="2" align="center">
<input type="submit" value=" Submit Form ">
</td>
</tr>
</table>
</form>

&copy 2006 By Novar <A HREF="http://www.novar.82ndid.com">novar.82ndid.com</a>[/code]

[code]<?
$mailto = 'jlluitj@gmail.com' ;
$subject = "RCT APP $game $name $age CoC=$coc" ;
$formurl = "http://www.novar.82ndid.com/index2.html" ;
$errorurl = "http://www.novar.82ndid.com/error.html" ;
$thankyouurl = "http://www.novar.82ndid.com/thanks.html" ;
$uself = 0;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$age = $_POST['age'] ;
$location = $_POST['location'] ;
$game = $_POST['game'] ;
$specialization = $_POST['specialization'] ;
$recommendation = $_POST['recommendation'] ;
$xfire = $_POST['xfire'] ;
$aim = $_POST['aim'] ;
$internet = $_POST['internet'] ;
$pastclans = $_POST['pastclans'] ;
$donate = $_POST['donate'] ;
$comments = $_POST['comments'] ;
$coc = $_POST['coc'] ;


$http_referrer = getenv( "HTTP_REFERER" );


if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name)
|| empty($email)
|| empty($age)
||empty ($location)
||empty ($game)
||empty ($recommendation)
||empty ($xfire)
||empty ($aim)
||empty ($donate)
||empty ($coc)) {
  header( "Location: $errorurl" );
  exit ;
}

if ( ereg( "[\r\n]", $name )
|| ereg( "[\r\n]", $age )
|| ereg( "[\r\n]", $email )
|| ereg( "[\r\n]", $location )
|| ereg( "[\r\n]", $game )
|| ereg( "[\r\n]", $recommendation )
|| ereg( "[\r\n]", $xfire )
|| ereg( "[\r\n]", $aim )
|| ereg( "[\r\n]", $donate )
|| ereg( "[\r\n]", $coc ) ) {
header( "Location: $errorurl" );
exit ;
}

if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of $name: $name\n" .
"Email of $name: $email\n" .
"Age of $name: $age\n" .
"Location of $name: $location\n" .
"Game of $name: $game\n" .
"Specialization of $name: $specialization\n" .
"Recommendation of $name: $recommendation\n" .
"Xfire of $name: $xfire\n" .
"AIM of $name: $aim\n" .
"Internet of $name: $internet\n" .
"Past Clans of $name: $pastclans\n" .
"Donate? of $name: $donate\n" .
"CoC of $name: $coc\n" .

"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: mail.php" );
header( "Location: $thankyouurl" );
exit ;

?>
[/code]
Link to comment
Share on other sites

Here is a simple one. Make sure that there are no spaces at the end of the file and that this is a seperate file NO HTML.

[code]<?php
$list = array("1","2","3","4","5","6","7","8","9","0",);

for ($i = 1; $i <= 6; $i++) {
$generated_code .= $list[rand(0,9)];
}

$im = @imagecreate (65, 24)
or die ("Cannot create code - please try later");
$background_color = imagecolorallocate ($im, 0, 0, 0);
$text_color = imagecolorallocate ($im, 255, 255, 255);
imagestring ($im, 5, 5, 5, $generated_code, $text_color);
imagepng ($im);
imagedestroy($im);
?>[/code]

You would use an image tag in html or php like this
[code]<img src="image.php" alt="Random Code" width="XX" height="XX">[/code]


You can click here for an example[url=http://www.owpt.biz/success.htm]Random Image[/url]

or you can go here for more information go here [url=http://www.zend.com/zend/tut/dynamic.php]http://www.zend.com/zend/tut/dynamic.php[/url]
Link to comment
Share on other sites

This code is designed for you to have a random number on top of a pictire and users have to
post the number for submission good luck.


no database required with this code it uses all sessions.


test.php

<?php
/* Session must always start at the very top of the php file! */
session_start();

if (isset($submit)) { // if user submitted the form
  if ($submit == "logout") { // if user wants to logout
      unset($_SESSION['key']); // unset the key
    }
  }

// if the key is wrong, or not excistant
if ($_SESSION['key'] != $_POST['key'] || (!($_SESSION['key']))) {
  $_SESSION['key'] = substr(md5(time()), 0, 6); // make a key
/* Make a form for inputing the key*/
  echo "
  <form action=\"\" method=\"post\">
  <img src=\"test_result.php\" />
  <input type=\"text\" name=\"key\" />

  <input type=\"submit\" name=\"submit\" value=\"submit\" />
  </form>";
  }
else { // if key is set and input is correct
// process the page
  echo "
  <form action=\"\" method=\"post\">
  Access OK
  <input type=\"submit\" name=\"submit\" value=\"logout\" />
  </form>";
  }
?>

Please fill in the xxxxxx ok
test_result

<?php
// once again, start the session at the very top!
session_start();

/* if there is a key */
if ($_SESSION['key']) {
/* define that the browser should treat
  the output of this file as an image */
  header("Content-type: image/png");

  // set the string to the key
  $string = $_SESSION['key'];

  // create an temporary image from a PNG file
  $im    = imagecreatefrompng("xxxfolder name xxx/xxx.png");

  // get a color from the image (in this case, yellow)
  $orange = imagecolorallocate($im, 220, 210, 60);

  /* Now we need to get widh and height of the image, so that we can center the
  key on the image, so that it does not go outside of the borders or look strange */
  $px    = (imagesx($im) - 7.5 * strlen($string)) / 2;
  $h = (imagesy($im) - 7.5) / 2;

  // here we write the key (the string)  on the image
  imagestring($im, 3, $px, $h, $string, $orange);

  // now create the final image
  imagepng($im);

  // to free up results, we need to destroy the temporary image.
  imagedestroy($im);
  }
?>

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.