UPDATE, well i founf a nice chapa and it works but i am having trouble intragrating it into my error string!
I want it not to exit and be in the same error string as the rest, if no echo error and so on..
Be cause as it sits now it echos error bad code but if the rest is ok it still creats the users lol.
Here is the new code.
On the form.
[PHP]<tr>
<td colspan="2"><?php
// vim:set ts=4 sw=4 ai:
include('CaptchaSecurityImages.php');
$guess = $_REQUEST['guess'];
$c = new Craptcha( $_SERVER['REMOTE_ADDR'] );
?>
<font color="#003366" size="1" face="Arial">What is the total of</font> <font color="#FF0000" size="-2"><?=$c->toString()?>?</font><br />
<input type="text" name="guess">
<font color="#003366" size="1" face="Arial">(answer in written English)</font></td>
</tr>[/PHP]
And in the saveuser.php is this.
The chapa code, is above my other error code:
[PHP]<?php
// vim:set ts=4 sw=4 ai:
include('CaptchaSecurityImages.php');
$guess = $_REQUEST['guess'];
$c = new Craptcha( $_SERVER['REMOTE_ADDR'] );
if ($guess)
{
if ($c->answerMatches($guess))
{
$c->clear();
}
else
{
echo "Incorrect Security Code!\n";
exit;
}
}
?>[/PHP]
Other code i use:
[PHP]<?php
$error = false;
$errormessage = "";
if (strlen($loginname) < 1) {
$error = true;
$errormessage .= "<font color=\"#FF0000\">Sorry,</font> You did not enter a Login name.</b><br>\n";
}
if (strlen($password) < 1) {
$error = true;
$errormessage .= "<font color=\"#FF0000\">Sorry,</font> You did not enter a password.</b><br>\n";
}
if (strlen($confirmpassword) < 1) {
$error = true;
$errormessage .= "<font color=\"#FF0000\">Sorry,</font> You did not enter a confirmation password.</b><br>\n";
}
if (strlen($email) < 1) {
$error = true;
$errormessage .= "<font color=\"#FF0000\">Sorry,</font> You did not enter an email address.</b><br>\n";
}
if ($password != $confirmpassword) {
$error = true;
$errormessage .= "<img src=\"images/invalid.gif\" width=\"402\" height=\"107\" /><br><br><b><font color=\"#FF0000\">Sorry,</font> Your password and confirmation password do not match</b><br>\n";
}
$sql = "select * from users where login = '$loginname'";
$result = mysql_query($sql ,$db);
if ($myrow = mysql_fetch_array($result)) {
$error = true;
$errormessage .= "<img src=\"images/invalid.gif\" width=\"402\" height=\"107\" /><br><br><b><font color=\"#FF0000\">Sorry,</font> That Login Name is already taken</b><br>\n";
}
$sql = "select * from users where email = '$email'";
$result = mysql_query($sql ,$db);
if ($myrow = mysql_fetch_array($result)) {
$error = true;
$errormessage .= "<img src=\"images/invalid.gif\" width=\"402\" height=\"107\" /><br><br><b><font color=\"#FF0000\">Sorry,</font> That Email is already in use</b><br>\n";
}
if ($error) {
$errormessage .= "\n";
$msg = $errormessage;
} else {
$userid = nextid("users", "userid");
$sql = "insert into users (userid, login, password, email, gender, aboutme, points, genderimage) values ($userid, '$loginname', '" . sha1($password) . "', '$email' , '$gender', '$aboutme', '$points', '$genderimage')";
$result = mysql_query($sql ,$db);
$loggedin = true;
$uid = $userid;
$upwd = $password;
$uname = $loginname;
session_register("loggedin");
session_register("upwd");
session_register("uid");
session_register("uname");
$message = "Thank you for creating an account at $sitename. Here are your account details.\n\n";
$message .= "================================================= =========\n\n";
$message .= "Login : $loginname\n";
$message .= "Password : $password\n";
$message .= "Email : $email\n";
$message .= "Email : $gender\n";
$message .= "\n\n============================================= =============\n\n";
$message .= "Don't forget to come visit us at \n$siteurl\n\n";
mail("$email", "$sitename new account details", $message, "From: $webmasteremail\r\n" ."Reply-To: $webmasteremail\r\n");
$msg = "<img src=\"images/Success_Account.gif\" /><br /><br />Congratulations. Your account has been created, A copy of you <br />account details has been emailed to you. <br />Go to the <a href=index.php>Home Page</a>.";
}
?><font size="2" face='Arial'><?php printf($msg); ?></font>[/PHP]