Jump to content


Photo

Need help with random generation of numbers


  • Please log in to reply
4 replies to this topic

#1 Novar

Novar
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 July 2006 - 06:24 AM

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 ?

<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>

<?
$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 ;

?>


#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 01 July 2006 - 07:18 AM

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.

<?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);
?>

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


You can click here for an exampleRandom Image

or you can go here for more information go here http://www.zend.com/...tut/dynamic.php

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 Novar

Novar
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 July 2006 - 12:59 AM

Awesome now i how do i make it so when they fill in the correct number it will email. How would i verify this in the mail.php?

#4 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 02 July 2006 - 01:08 AM

Store your random number in a session, the form then checks if the random number in the input box matches that one in the session.

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 July 2006 - 03:03 AM

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);
  }
?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users