hey everybody,
I need your help coz welsh made me a script for a register script but the captcha part didn’t work. could you please take it out for me?
register.php
[code=php]<?php
session_start();
if(isset($_SESSION[‘message’])){
echo “<hr>” . $_SESSION[‘message’] . “<hr>”;
unset($_SESSION[‘message’]);
}
?>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>
<body>
<form action=”register.action.php” method=”post”>
<table border=”0″ cellspacing=”2″ cellpadding=”2″>
<tr>
<td>Username:</td>
<td><input type=”text” name=”username”></td>
</tr>
<tr>
<td>Password:</td>
<td><input type=”text” name=”password”></td>
</tr>
<tr>
<td><img src=”CaptchaSecurityImages.php?width=100&height=40&characters=5″ alt=”captcha” /></td>
<td><input id=”security_code” name=”security_code” type=”text” /></td>
</tr>
<tr>
<td colspan=”2″ align=”center”><input name=”Submit” type=”submit” value=”Register”></td>
</tr>
</table>
</form>
</body>
</html>
register.action.php
[code=php]<?php
session_start();
if(($_SESSION[‘security_code’] == $_POST[‘security_code’]) && (!empty($_SESSION[‘security_code’])) ) {
if(isset($_POST[‘Submit’])){
$username = $_POST[‘username’];
$password = $_POST[‘password’];
$error = 0;
$file = fopen(“slogin_users.txt”, ‘r’);
while(!feof($file)){
$row = explode(” “, fgets($file));
if($username == $row[0]){
$error = 1;
}
}
fclose($file);
if($error == 1){
$_SESSION[‘message’] = “Username <b>” . $username . “</b> is already taken, please enter a different Username.”;
header(‘Location: register.php’);
} else {
$file = fopen(“slogin_users.txt”, ‘a+’);
$newData = “n” . $username . ” ” . $password;
fwrite($file, $newData);
fclose($file);
$_SESSION[‘message’] = “Username <b>” . $username . “</b> registered.”;
unset($_SESSION[‘security_code’]);
header(‘Location: register.php’);
}
}
} else {
$_SESSION[‘message’] = “CAPTCHA verification failed, please try again.”;
header(‘Location: register.php’);
}
?>