Jump to content

My code registers blank records


SirChick

Recommended Posts

heres my html as asked by Teng :)

 

<html>

<head>

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

<title>Untitled Page</title>

<meta name="GENERATOR" content="Created by BlueVoda">

<script language="JavaScript" type="text/javascript">

<!--

function ValidateForm1(theForm)

{

var strFilter = /^[A-Za-zƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-]*$/;

var chkVal = theForm.Editbox2.value;

if (!strFilter.test(chkVal))

{

  alert("Username must be letters or numbers only, minimum of 3 and maximum of 11 characters.");

  theForm.Editbox2.focus();

  return false;

}

if (theForm.Editbox2.value == "")

{

  alert("Username must be letters or numbers only, minimum of 3 and maximum of 11 characters.");

  theForm.Editbox2.focus();

  return false;

}

if (theForm.Editbox2.value.length < 3)

{

  alert("Username must be letters or numbers only, minimum of 3 and maximum of 11 characters.");

  theForm.Editbox2.focus();

  return false;

}

if (theForm.Editbox2.value.length > 11)

{

  alert("Username must be letters or numbers only, minimum of 3 and maximum of 11 characters.");

  theForm.Editbox2.focus();

  return false;

}

var strFilter = /^[A-Za-zƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-]*$/;

var chkVal = theForm.Editbox1.value;

if (!strFilter.test(chkVal))

{

  alert("Passwords must be minimum 5 to maximum 15 characters long!");

  theForm.Editbox1.focus();

  return false;

}

if (theForm.Editbox1.value == "")

{

  alert("Passwords must be minimum 5 to maximum 15 characters long!");

  theForm.Editbox1.focus();

  return false;

}

if (theForm.Editbox1.value.length < 5)

{

  alert("Passwords must be minimum 5 to maximum 15 characters long!");

  theForm.Editbox1.focus();

  return false;

}

if (theForm.Editbox1.value.length > 15)

{

  alert("Passwords must be minimum 5 to maximum 15 characters long!");

  theForm.Editbox1.focus();

  return false;

}

var strFilter = /^[A-Za-zƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-]*$/;

var chkVal = theForm.Editbox4.value;

if (!strFilter.test(chkVal))

{

  alert("Passwords must be minimum 5 to maximum 15 characters long!");

  theForm.Editbox4.focus();

  return false;

}

if (theForm.Editbox4.value == "")

{

  alert("Passwords must be minimum 5 to maximum 15 characters long!");

  theForm.Editbox4.focus();

  return false;

}

var strValue = theForm.Editbox3.value;

var strFilter = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;

if (!strFilter.test(strValue))

{

  alert("Must be a valid email address!");

  return false;

}

if (theForm.Editbox3.value == "")

{

  alert("Must be a valid email address!");

  theForm.Editbox3.focus();

  return false;

}

if (theForm.Editbox3.value.length < 1)

{

  alert("Must be a valid email address!");

  theForm.Editbox3.focus();

  return false;

}

if (theForm.Combobox1.selectedIndex < 0)

{

  alert("Please select one of the \"Country Choice\" options.");

  theForm.Combobox1.focus();

  return false;

}

if (theForm.Combobox1.selectedIndex == 0)

{

  alert("The first \"Country Choice\" option is not a valid selection.  Please choose one of the other options.");

  theForm.Combobox1.focus();

  return false;

}

return true;

}

//-->

</script>

</head>

<body bgcolor="#466B98" text="#000000" style="scrollbar-face-color:#C8E8F8;scrollbar-arrow-color:#000000;scrollbar-3dlight-color:#C8E8F8;scrollbar-darkshadow-color:#404040;scrollbar-highlight-color:#E8F4FF;scrollbar-shadow-color:#40B0E8;scrollbar-track-color:#E8F4FF;">

<img src="Banner1_05_37.jpg" id="Image1" alt="" align="top" border="3" width="994" height="94" style="position:absolute;left:0px;top:0px;width:994px;height:94px;border-color:#FFFFFF;z-index:20">

<div id="bv_" style="position:absolute;left:78px;top:457px;width:779px;height:319px;z-index:21" align="left">

 

 

<form name="registration" method="POST" action="" enctype="multipart/form-data" id="Form1" onsubmit="return ValidateForm1(this)">
<center><img src="CaptchaSecurityImages.php" /><b><font style="font-size:13px" color="#FFFFFF" face="Arial">Security Code: 
<input id="security_code" name="security_code" type="text" /></center>
<input type="text" id="Editbox2" style="position:absolute;left:193px;top:44px;width:144px;font-family:Courier;font-size:19px;z-index:0" size="16" name="Username" value="" maxlength="11">
<input type="password" id="Editbox1" style="position:absolute;left:194px;top:85px;width:144px;font-family:Courier;font-size:19px;z-index:1" size="16" name="Password" value="" maxlength="15">
<input type="password" id="Editbox4" style="position:absolute;left:193px;top:123px;width:144px;font-family:Courier;font-size:19px;z-index:2" size="16" name="Password2" value="" maxlength="15">
<div id="bv_Text1" style="position:absolute;left:31px;top:49px;width:150px;height:16px;z-index:3" align="left">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Enter Your Username : </b></font></div>
<div id="bv_Text2" style="position:absolute;left:34px;top:91px;width:150px;height:16px;z-index:4" align="left">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Enter Your Password :</b></font></div>
<div id="bv_Text3" style="position:absolute;left:14px;top:129px;width:170px;height:16px;z-index:5" align="left">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Re-Enter Your Password :</b></font></div>
<input type="text" id="Editbox3" style="position:absolute;left:194px;top:162px;width:144px;font-family:Courier;font-size:19px;z-index:6" size="16" name="EmailRegistration" value="">
<div id="bv_Text4" style="position:absolute;left:70px;top:163px;width:112px;height:16px;z-index:7" align="left">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Email Addresss :</b></font></div>
<hr size="60" width="168" id="Line2" style="position:absolute;left:379px;top:42px;width:168px;height:60px;z-index:8">
<div id="bv_Text5" style="position:absolute;left:377px;top:52px;width:73px;height:16px;z-index:9" align="center">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Gender :</b></font></div>
<input type="radio" id="RadioButton2"" name="Gender" value="Male" checked style="position:absolute;left:447px;top:51px;z-index:10">
<div id="bv_Text6" style="position:absolute;left:471px;top:53px;width:61px;height:16px;z-index:11" align="center">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Male</b></font></div>
<input type="radio" id="RadioButton1"" name="Gender" value="Female" style="position:absolute;left:447px;top:79px;z-index:12">
<div id="bv_Text7" style="position:absolute;left:471px;top:83px;width:66px;height:16px;z-index:13" align="center">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Female</b></font></div>
<hr size="56" width="237" id="Line1" style="position:absolute;left:379px;top:128px;width:237px;height:56px;z-index:14">
<div id="bv_Text9" style="position:absolute;left:395px;top:139px;width:170px;height:32px;z-index:15" align="left">


<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>I Agree to Civilian's Terms Of Service:</b></font></div>
<input type="checkbox" id="Checkbox2"" name="TermsOfService" value="" style="position:absolute;left:474px;top:153px;z-index:16">


<input type="submit" id="Button2"" name="RegistrationSubmission" value="Register!" style="position:absolute;left:679px;top:90px;width:75px;height:24px;z-index:17">
<div id="bv_Text11" style="position:absolute;left:29px;top:206px;width:150px;height:16px;z-index:18" align="center">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Game Country Choice:</b></font></div>
<select name="CountryChoice" size="1" id="Combobox1" style="position:absolute;left:192px;top:203px;width:150px;font-family:MS Shell Dlg;z-index:19">
<option></option>
<option>United Kingdom</option>
</select>
</form>
</div>

 

<div id="bv_" style="position:absolute;left:278px;top:814px;width:329px;height:100px;z-index:22" align="center">

<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>By clicking the button above you are agreeing to Civilian's<br>

Terms Of Service. <br>

<font style="font-size:15px" color="#FFFFFF" face="Arial">If you get offended easily, please do not join.<br>

<br>

</b></font></div>

<div id="bv_" style="position:absolute;left:317px;top:147px;width:345px;height:284px;z-index:23" align="left">

<img src="bv01023.gif" id="Shape2" align="top" alt="" border="0" width="345" height="284"></div>

<div id="bv_" style="position:absolute;left:318px;top:165px;width:337px;height:44px;z-index:24" align="center">

<font style="font-size:19px" color="#000000" face="Arial"><b><u>Please read the rules of the game here before you contine!</u></b></font></div>

<div id="bv_" style="position:absolute;left:352px;top:229px;width:256px;height:194px;z-index:25" align="left">

<table width="100%" border="0" cellpadding="0" cellspacing="2" id="BulletedList2">

<tr>

<td align="left" valign="top" width="72" height="50"><font style="font-size:13px;" color="#000000" face="Wingdings">¡</font></td>

<td align="left" valign="top" width="178" height="50"><font style="font-size:13px" color="#000000" face="Arial">Multiple Accounts is not allowed and will result in a permanent ban.</font></td>

</tr>

<tr>

<td align="left" valign="top" width="72" height="50"><font style="font-size:13px;" color="#000000" face="Wingdings">¡</font></td>

<td align="left" valign="top" width="178" height="50"><font style="font-size:13px" color="#000000" face="Arial">Users must be over 13. If you are not over 13 ask your parents for permission first.</font></td>

</tr>

<tr>

<td align="left" valign="top" width="72" height="34"><font style="font-size:13px;" color="#000000" face="Wingdings">¡</font></td>

<td align="left" valign="top" width="178" height="34"><font style="font-size:13px" color="#000000" face="Arial">Respect other players and they will respect you!</font></td>

</tr>

<tr>

<td align="left" valign="top" width="72" height="50"><font style="font-size:13px;" color="#000000" face="Wingdings">¡</font></td>

<td align="left" valign="top" width="178" height="50"><font style="font-size:13px" color="#000000" face="Arial">Spam & advertisements of other sites not allowed and will result a permanent ban.</font></td>

</tr>

</table></div>

<div id="bv_" style="position:absolute;left:134px;top:232px;width:150px;height:144px;z-index:26" align="center">

<font style="font-size:13px" color="#FFFFFF" face="Arial">Please make sure you have read the rules to the right hand side.<br>

<br>

<br>

Also make sure you agree to the:<br>

<br>

<b><u>Terms Of Service</u></b></font></div>

</body>

</html>

Link to comment
Share on other sites

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

oops sos my bad i posted the wrong page. Here it is again i put the form in php tags so its in color to stand out and the termsofservice i put some blank lines above and below it so you can see it properly...

 

 

See previous post i modified it :)

 

the is the exact html for it in the form

<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>I Agree to Civilian's Terms Of Service:</b></font></div>
<input type="checkbox" id="Checkbox2"" name="TermsOfService" value="" style="position:absolute;left:474px;top:153px;z-index:16">

Link to comment
Share on other sites

if thats the original code you have then you have wrong html code

<input type="checkbox" id="Checkbox2"" name="TermsOfService" value="" style="position:absolute;left:474px;top:153px;z-index:16">

see this id="Checkbox2"" loooook at the "" it double use only

id="Checkbox2"

Link to comment
Share on other sites

Damn you got an eye like an eagle !! Mind you when you work hours on these things my eye sharpness drops over too much concentration :P

 

But still not totally working :/

 

There captcha security image generator doesn't produce an error when the user's input doesnt match the image.

 

I provided the code for it just a bit further up in this thread (thats the last part of it) i promise ;)

Link to comment
Share on other sites

no no sorry i think i might have worded it wrongly.

 

Basically say the image produced had "gdgdg"

 

and the user put "dgfdgfsdgsdsagf" it should say "Your input did not match the security image" but instead it just ignores it and carrys on..

Link to comment
Share on other sites

looking at your code you have this

  if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {

 

so echo all the value for that and see the result if it really satisfy the condition

 

and do it something like this i guess its better

   if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'])) {

Link to comment
Share on other sites

ok tell me where and how do you use this

 

function generateCode($characters) {

      /* list all possible characters, similar looking characters and vowels have been removed */

      $possible = '23456789bcdfghjkmnpqrstvwxyz';

      $code = '';

      $i = 0;

      while ($i < $characters) {

        $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);

        $i++;

      }

      return $code;

  }

thats from you captcha thing

Link to comment
Share on other sites

that is on a separate php file in the directory.

 

that basically produces which letters will and will not show... it uses a special type of font format which is also in the directory. That basically declares the security code ready to be echo'd.

 

i was quite proud of myself given i coded so much and it worked then everyone went "put injection prevention in and a captcha" now it screwed up! back to being a noob when yesterday i felt like i had made progress lol! i do appreciate the help big time! u will deffo be mentioned and a BIG help on my site thats for sure :P

 

ill get some sleep its 2am here again lol! shall check back in the morning! thanks again teng

 

(And don't use up all your free time on me, ill feel guilty!! more than i already do!)

Link to comment
Share on other sites

tip if u intalled package like wamp look for the folder for phpmyadmin and create a folder

beside not inside that serves as your directory

 

look type this in your browser localhost/phpmyadmin and you will get the page for that

hope you know what i mean

Link to comment
Share on other sites

I have xampp package. Im unfamiliar with wamp. My url i put into my browser to load the reg page is:

 

localhost/registerpage.php

 

when i did

 

"localhost/phpmyadmin" - I was taken to my apache database. "phpMyAdmin - 2.10.1"

 

 

what do you mean by serves as your directory? for which files are you referring to ?

 

My html files are found in:

 

C:\xampp\htdocs\

Link to comment
Share on other sites

looking at your code you have this

  if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {

 

so echo all the value for that and see the result if it really satisfy the condition

 

and do it something like this i guess its better

 

[quote author=teng84 link=topic=152708.msg661197#msg661197

date=1186099831]

ok tell me where and how do you use this

 

function generateCode($characters) {

      /* list all possible characters, similar looking characters and vowels have been removed */

      $possible = '23456789bcdfghjkmnpqrstvwxyz';

      $code = '';

      $i = 0;

      while ($i < $characters) {

        $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);

        $i++;

      }

      return $code;

  }

thats from you captcha thing

 

do this

   if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'])) {

and where did $_SESSION['security_code'] being initialize i see thats its in the captcha code but look carefully how you or where is the value of this

$code in the capcha code ????

Link to comment
Share on other sites

basically :

 

$code  is this:

 

 

$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);

 

 

that will equal what $code is.

 

Right at the end of my captcha code i have this:

 

$_SESSION['security_code'] = $code;

 

Which then leads onto the registration page:

 

 

 

 if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'])) {

 

 

the

$_POST['security_code']

 

is the html form now and the html for the input box for the security code is:

 

<center>

<input id="security_code" name="security_code" type="text" /></center>

 

 

 

This is how it becomes an image file:

 

imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code)

 

and this is what displays it on the page:

 

<img src="CaptchaSecurityImages.php" /><b><font style="font-size:13px" color="#FFFFFF" face="Arial">

Link to comment
Share on other sites

I have post both php files as both are needed in order to work so i may aswell give you the entire thing together:

 

Registerpage.php:

 

<?php

if(!mysql_connect("localhost", "root", "private")){
echo mysql_error();
exit;
}
else{
mysql_select_db("civilian") or die (mysql_error());
if (isset($_POST['RegistrationSubmission'])){
session_start();

   
   $Captcha = ($S_SESSION['security_code']);
   $UserCaptcha = mysql_real_escape_string($_POST['security_code']);
   if($Captcha == $UserCaptcha){
      // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
  $Username = mysql_real_escape_string($_POST['Username']); 
	$Password = mysql_real_escape_string($_POST['Password']); 
	$Password2 = mysql_real_escape_string($_POST['Password2']);
	$Email = mysql_real_escape_string($_POST['EmailRegistration']);
	$Country = mysql_real_escape_string($_POST['CountryChoice']);
	$ip = $_SERVER["REMOTE_ADDR"];
	$Gender = $_POST['Gender'];
	$TermsOfService = $_POST['TermsOfService'];
	$jump2 = 1;
  if ($Password != $Password2) {
		echo "Passwords did not match";
			if ($TermsOfService == "off") {

				die('You must agree to the terms of service before registering! Please press back and try again!');
				$jump2 = 0;
			}
		}
		if ($jump2 ==1){
			$chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'");
			$getUSERNAME = mysql_fetch_assoc($chkUSERNAME);
			 if($_POST['Username'] == $getUSERNAME['Username']) {
				  die('Username already registered, please choose a different username! That has not already been taken!');
			 }
			$chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'");
			$getEmail = mysql_fetch_assoc($chkEmail);
			if($_POST['EmailRegistration'] == $getEmail['Email']) {
				  die('Email is already in use please use a different valid email address!!');
			}
		 if ($Password == $Password2) {
			$query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) 
					  Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')";
			mysql_query($query) or die(mysql_error());
      unset($_SESSION['security_code']);
   }}} else {
      // Insert your code for showing an error message here
  If($Captcha != $UserCaptcha){
	die('Your security code did not match the generated image, please try again!');
  }}
   }}
?>

 

 

CaptchaSecurityImage.php

 

<?php
session_start();

/*
* File: CaptchaSecurityImages.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 03/08/06
* Updated: 07/02/07
* Requirements: PHP 4/5 with GD and FreeType libraries
* Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php
* 
* This program is free software; you can redistribute it and/or 
* modify it under the terms of the GNU General Public License 
* as published by the Free Software Foundation; either version 2 
* of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful, 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
* GNU General Public License for more details: 
* http://www.gnu.org/licenses/gpl.html
*
*/

class CaptchaSecurityImages {

   var $font = 'monofont.ttf';

   function generateCode($characters) {
      /* list all possible characters, similar looking characters and vowels have been removed */
      $possible = '23456789bcdfghjkmnpqrstvwxyz';
      $code = '';
      $i = 0;
      while ($i < $characters) { 
         $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
         $i++;
      }
      return $code;
   }

   function CaptchaSecurityImages($width='120',$height='40',$characters='6') {
      $code = $this->generateCode($characters);
      /* font size will be 75% of the image height */
      $font_size = $height * 0.75;
      $image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
      /* set the colours */
      $background_color = imagecolorallocate($image, 255, 255, 255);
      $text_color = imagecolorallocate($image, 20, 40, 100);
      $noise_color = imagecolorallocate($image, 100, 120, 180);
      /* generate random dots in background */
      for( $i=0; $i<($width*$height)/3; $i++ ) {
         imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
      }
      /* generate random lines in background */
      for( $i=0; $i<($width*$height)/150; $i++ ) {
         imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
      }
      /* create textbox and add text */
      $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
      $x = ($width - $textbox[4])/2;
      $y = ($height - $textbox[5])/2;
      imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
      /* output captcha image to browser */
      header('Content-Type: image/jpeg');
      imagejpeg($image);
      imagedestroy($image);
      $_SESSION['security_code'] = $code;
   }

}

$width = isset($_GET['width']) && $_GET['height'] < 600 ? $_GET['width'] : '120';
$height = isset($_GET['height']) && $_GET['height'] < 200 ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) && $_GET['characters'] > 2 ? $_GET['characters'] : '6';

$captcha = new CaptchaSecurityImages($width,$height,$characters);

?>

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.