Hello I have a registration page for my site with an image code on it. I was wondering if somebody could help me make the captcha a link so that it would generate a new captcha.
Here's my page:
http://www.ootaclan.org/test/register.php
Here's the code from that page:
<?php
session_start();
include("db.php");
include("mainfile.php");
include("securimage.php");
docstart();
dochead();
function usernameTaken($username) {
global $conn;
if(!get_magic_quotes_gpc()){
$username = addslashes($username);
}
$q = "select username from users where username = '$username'";
$result = mysql_query($q,$conn);
return (mysql_numrows($result) > 0);
}
function addNewUser($username, $password, $realname, $email, $website, $icq, $aim, $yim, $msn, $location, $occupation, $interests) {
global $conn;
$q = "INSERT INTO users VALUES ('$username', '$password', '$realname', '$email', '$website', '$icq', '$aim', '$yim', '$msn', '$location', '$occupation', '$interests')";
return mysql_query($q,$conn);
}
function displayStatus() {
$uname = $_SESSION['reguname'];
if($_SESSION['regresult']) {
echo "<font color='C0C0C0'><h1>Registered!</h1>\n";
echo "<p>Thank You <b>" . $uname . "</b>, your information has been added to our database, you may now <a href='index.php' title='Login'>log in</a>.</font>\n";
}
else {
echo "<h1>Registration Failed</h1>";
echo "<p>We are sorry, but an error has occured and your registration for the username <b>" . $uname . "</b>, could not be completed.<br>";
echo "Please try again at a later time.";
}
unset($_SESSION['reguname']);
unset($_SESSION['registered']);
unset($_SESSION['regresult']);
}
if(isset($_SESSION['registered'])) {
docstart();
displayStatus();
return;
}
if(isset($_POST['subjoin'])) {
if(!$_POST['user'] || !$_POST['pass'] || !$_POST['confirmpass'] || !$_POST['email'] || !$_POST['confirmemail'] || !$_POST['realname']) {
die("<font color=\"#c0c0c0\">You didn't fill in a required field.<br><a href='register.php' target='_self'>Click here to try again</a></font>");
}
$_POST['user'] = trim($_POST['user']);
if(strlen($_POST['user']) > 30) {
die("<font color=\"#c0c0c0\">Sorry, the username is longer than 30 characters, please shorten it.<br><a href='register.php' target='_self'>Click here to try again</a></font>");
}
$pass1 = md5($_POST['pass']);
$pass2 = md5($_POST['confirmpass']);
if($pass1 != $pass2) {
die("<font color=\"#c0c0c0\">Your Passwords do not match<br>Please try re-entering your passwords<br><a href='register.php' target='_self'>Click here to try again</a></font>");
}
if($_POST['email'] != $_POST['confirmemail']) {
die("<font color=\"#c0c0c0\">Your Email Addresses do not Match<br>Please try again.<br><a href='register.php' target='_self'>Click here to try again</a></font>");
}
$img = new Securimage();
$valid = $img->check($_POST['code']);
if($valid == false) {
die("<font color=\"#c0c0c0\">Sorry The Image Code you Entered is incorrect!<br><br><a href=\"javascript:history.go(-1)\">Please try Again</a></font>");
}
if(usernameTaken($_POST['user'])) {
$use = $_POST['user'];
die("<font color=\"#c0c0c0\">Sorry, the username: <strong>$use</strong> is already taken, please pick another one.<br><a href='register.php' target='_self'>Click here to try again</a></font>");
}
$md5pass = md5($_POST['pass']);
$_SESSION['reguname'] = $_POST['user'];
$_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass, $_POST['realname'], $_POST['email'], $_POST['website'], $_POST['icq'], $_POST['aim'], $_POST['yim'], $_POST['msn'], $_POST['location'], $_POST['occupation'], $_POST['interests']);
$_SESSION['registered'] = true;
echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[PHP_SELF]\">";
return;
}
else {
?>
<div align="center">
<table border="0" width="1060" id="bodytabel" height="185" bgcolor="#000000" cellspacing="0" cellpadding="0">
<tr>
<td width="150" bgcolor="#212121"></td>
<td width="5"></td>
<td width="750"></td>
<td width="5"></td>
<td width="150" bgcolor="#212121"></td>
</tr>
<tr>
<td width="150" bgcolor="#212121" rowspan="2" align="center" valign="top">
</td>
<td width="5"> </td>
<td width="750" rowspan="33"><div align="center"><font color="C0C0C0">
<h1>Register</h1></font>
<p><font color="#FF0000">* </font><font color="C0C0C0">- Indicates Required Field(s)</font></p>
<form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
<table align="center" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><font color="C0C0C0">Username:</font> <font color="#FF0000">*</font></td>
<td><input type="text" name="user" maxlength="30"></td>
</tr>
<tr>
<td><font color="C0C0C0">Password:</font><font color="#FF0000"> *</font></td>
<td><input type="password" name="pass" maxlength="30"></td>
</tr>
<tr>
<td><font color="C0C0C0">Confirm Password:</font> <font color="#FF0000">*</font></td>
<td><input type="password" name="confirmpass" maxlength="30"></td>
</tr>
<tr>
<td><font color="C0C0C0">Email:</font> <font color="#FF0000">*</font></td>
<td><input type="text" name="email" maxlength="250"></td>
</tr>
<tr>
<td><font color="C0C0C0">Confirm Email:</font> <font color="#FF0000">*</font></td>
<td><input type="text" name="confirmemail" maxlength="250"></td>
</tr>
<tr>
<td><font color="C0C0C0">Real Name:</font> <font color="#FF0000">*</font></td>
<td><input type="text" name="realname" maxlength="55"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td><font color="#C0C0C0">Website:</font></td>
<td><input type="text" name="website" maxlength="250"></td>
</tr>
<tr>
<td><font color="#C0C0C0">ICQ:</font></td>
<td><input type="text" name="icq" maxlength="15"></td>
</tr>
<tr>
<td><font color="#C0C0C0">AIM:</font></td>
<td><input type="text" name="aim" maxlength="18"></td>
</tr>
<tr>
<td><font color="#C0C0C0">YIM:</font></td>
<td><input type="text" name="yim" maxlength="25"></td>
</tr>
<tr>
<td><font color="#C0C0C0">MSN:</font></td>
<td><input type="text" name="msn" maxlength="25"></td>
</tr>
<tr>
<td><font color="#C0C0C0">Location:</font></td>
<td><input type="text" name="location" maxlength="250"></td>
</tr>
<tr>
<td><font color="#C0C0C0">Occupation:</font></td>
<td><input type="text" name="occupation" maxlength="250"></td>
</tr>
<tr>
<td><font color="#C0C0C0">Interests:</font></td>
<td><input type="text" name="interests" maxlength="250"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><font color="#c0c0c0">Please enter the image code shown below.</font>
<font color="#FF0000">*</font><br>
<font color="#c0c0c0">(Enter with no spaces. Characters are not case-sensitive)</font></td>
</tr>
<tr>
<td><input type="text" name="code"></td>
<td><img src="securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>"></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="subjoin" value="Register!"></td>
</tr>
</table>
</form></div></td>
<td width="5"> </td>
<td width="150" bgcolor="#212121"> </td>
</tr>
</table>
</div>
</body>
</html>
<?php
}
echo "<div align='center'>";
footer();
echo "</div";
?>
I just want the user to be able to click the image verification code and it would make a new one. (in case they can't read it or somthing)
(Note: I had to delete some of the html code above to make it fit.
I'd appreciate any help i can get.