Home Articles CV / Résumé Downloads Photo Gallery Web LinksJanuary 09 2009 19:28:32
Validation Code Contact Me Form
There are two files here that are modified, maincore.php and contact.php, make sure to back up both of these files now.

Let's start with contact.php, where most of the changes are gonna be, at about line 63
<tr><td valign='top' width='90'>".$locale['405']."</td>
<td><textarea name='message' rows='10' class='textbox' style='width: 320px'></textarea></td>
</tr>
<tr>
<td align='center' colspan='2'>
<input type='submit' name='sendmessage' value='".$locale['406']."' class='button'>
</td>
</tr>
where we will add code to show the validation code and also ask the user for it,
<tr><td valign='top' width='90'>".$locale['405']."</td>
<td><textarea name='message' rows='10' class='textbox' style='width: 320px'></textarea></td>
</tr>";
$locale['504'] = "Validation Code:";
$locale['505'] = "Enter Validation Code:";

echo "<tr>\n<td class='tbl'>".$locale['504']."</td>\n<td class='tbl'>";

srand((double)microtime()*1000000);
$temp_num = md5(rand(0,9999));
$vcode_1 = substr($temp_num, 17, 5);
$vcode_2 = md5($vcode_1);
unset($temp_num);
$result = dbquery("INSERT INTO ".$db_prefix."vcode VALUES('".time()."', '$vcode_1', '$vcode_2')");

if ($settings['validation_method'] == "image") {
echo "<img xsrc='?vimage_c=$vcode_2'>\n";
} else {
echo "<b>$vcode_1</b>\n";
}
unset($vcode_1,$vcode_2);
echo "</td>\n</tr>\n";
echo "<tr>
<td class='tbl'>".$locale['505']."<span style='color:#ff0000'>*</span></td>
<td class='tbl'><input type='text' name='user_code' class='textbox' style='width:100px'></td>
</tr>\n

<tr>
<td align='center' colspan='2'>
<input type='submit' name='sendmessage' value='".$locale['406']."' class='button'>
</td>
</tr>

as you read the code above, you'll notice that there are some locales that it calls for, these are not defined for this file, yet, we will add there definition later. The only reason I don't call the default locale file where these are from is that it would overlap with some of the other locales and screw things up royally, so its just best to add these two fields to this file (as is done by the two lines in brown). (if you really want to try it, add the following to the top of contact.php and you'll see
include LOCALE.LOCALESET."register.php";
if it does work for you without fail, then great let me know ... i might have done something else wrong!)

now back to on track, the code above that we added is the creation of the validation code (code in blue) and then the display and request of it (code in red) ... but we still have to make sure that the code entered is actually valid and correct!

so we go up to line 31, where the information put in the contact me form is checked before email being sent out .. we are gonna add the validation code check here,
if ($message == "") {
$error .= "ˇ <span class='alt'>".$locale['423']."</span><br>\n";
}
will become
if ($message == "") {
$error .= "ˇ <span class='alt'>".$locale['423']."</span><br>\n";
}
$user_code = stripinput($_POST['user_code']);
$result = dbquery("SELECT * FROM ".$db_prefix."vcode WHERE vcode_1='$user_code'");
$locale['410'] = "Incorrect validation code.";
if (dbrows($result) == 0) {
$error .= "ˇ <span class='alt'>".$locale['410']."</span><br>\n";
} else {
$result = dbquery("DELETE FROM ".$db_prefix."vcode WHERE vcode_1='$user_code'");
}

the added code here will make sure that the entered validation code is correct or else it will throw back an error.

that's it for this file, save and close it.
Page 1 of 2 1 2 >
Post Comment
Name:



Smile Wink Frown Sad Shock Pinch Cool Grin Angry Roll Uh-oh! Thumbs Down Sleep Laughing Dead Ouch Mad Tongue Clap Hug Geek Confused Thumbs Up Shy Laugh Asking Fingers Crossed Yahoo
2 + 1=
Disable smileys in this comment

Comments
Jacoby253 on December 28 2007 03:46:26
Maimouna xx Shopping Free Crashing Carts Music xx Free Music Mix In The xx Software As Hardware Mp3 xx Free Download A.m.g.o.d. xx Of Free The Music Download Riddick Free Chronicles xx Music Project Free Medusa xx I Love xx (dfunkd025) Free Defunked Music xx Free All The Download In Game xx Cryogenix xx Sea Me Free Wash Goodbye Music A Its A xx Promo Love Cds Soon Too xx Passion Sunrise (live) xx Legends xx Planet Mp3 Red xx Free Che Vita Ma La Film Download xx Guitars Of Androgynous Six / Study A Amorphous xx Ronski Speed xx Download Free Mind Wars
Adnan on April 22 2007 16:01:37
Trust me i've tried a thousand times, but something about the parsing of the article text adds that x for img src to become img xsrc.

Sorry but haven't found a way out of it yet.
Priyank Bolia on April 22 2007 15:48:12
Change xsrc to src
miller on October 30 2006 16:53:43
holla, i've just tested this codes on v6.00.306 and works perfect ...thanks Adnan.. your'e tha man
dtommy79 on September 10 2006 18:02:41
I can't see the validation code image. What did I miss?
Ratings
Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.

This site is optimized for viewing with Firefox!
All articles, pictures, and any other material obtained from this site is Copyright © 2007, and may not be reproduced without permission from the author.
Link Exchange - Directory - Windows Hosting