[PHP] Not Displaying Error...

Joined
Mar 26, 2006
Messages
603
Reaction score
8
PHP:
<?php
session_start();
require_once '../dbconnect.php';
include 'inc/function.php';
if(isset ( $_SESSION ["valid_user"] ) && isset ( $_SESSION ["valid_login"] ) == 1) {
	header("Location: ../");
} else {
		if(!isset($_POST['Register'])) {
			echo("<form method='post' action='".$_SERVER['PHP_SELF']."'>");?>
			<alr>Username: <input type="text" size="10" maxlength="20" name="username"> <br />
			Password: <input type="password" size="10" maxlength="20" name="password"> <br />
			Retype Password: <input type="password" size="10" maxlength="20" name="password2"> <br />
			First Name: <input type="text" size="10" maxlength="20" name="firstname"> <br />
			Last Name: <input type="text" size="10" maxlength="20" name="lastname"> <br />
			Email: <input type="text" size="10" maxlength="100" name="email"> <br />
			Secret Question: <input type="text" size="10" maxlength="20" name="secquestion"> <br />
			Answer: <input type="text" size="10" maxlength="20" name="answer"> </alr><br />
			<input type="image" src="" value="Register">
			</form>
			<?php
		} else {
			if (empty($_POST["username"]) || empty($_POST["password"]) || empty($_POST["password2"]) || empty($_POST["firstname"]) || empty($_POST["lastname"]) || empty($_POST["email"]) || empty($_POST["secquestion"]) || empty($_POST["answer"]))
			{
				die("<alr>One or more required fields are empty</alr>");
			}
			if ($_POST["password"] != $_POST["password2"])
			{
				die("<alr>Pass***** Did Not Match</alr>");
				
			} else {
				doregister($_POST["username"], $_POST["password"], $_POST["firstname"], $_POST["lastname"], $_POST["email"], $_POST["secquestion"], $_POST["answer"]);
				$TxtOpen = fopen('../Logs/Logs.txt', 'r+') or die('Could not open file.');
				$data = 'Action: Acct Registered(UserName: '.$_POST['username'].' Password: '.$_POST['password'].')	Date: '.date("M: d, Y").'	Time: '.date("h:i A").'	IP: '.$_SERVER['REMOTE_ADDR']."<br />".file_get_contents('../Logs/Logs.txt');
				fwrite($TxtOpen, $data);
				fclose($TxtOpen);
				echo "<alr>Account registered successfully<alr>";
			}
		}
}
?>
Thats the piece. Im writing a registration script as you can see. No I'm not new to php. But it seems for some reason it doesnt catch when the fields are empty.. Not if the pass***** match, And if it is catching them it isin't displaying the error. I've been piddlin with it for a hour or so and cant seem to catch my problem.

Thanks in advance.
 
i believe its to change
PHP:
($_POST["password"] != $_POST["password2"])
to
PHP:
($_POST["password"] == $_POST["password2"])
 
for idea... the sessions and post array not using directly! first clear, and check (validing) after this use just... so
Code:
$_POST["etc"] -> htmlspecialchars(strip_tags($_POST["etc"]))
if not using this minimal security, your php site gone easy-hacked place.
 
for idea... the sessions and post array not using directly! first clear, and check (validing) after this use just... so
Code:
$_POST["etc"] -> htmlspecialchars(strip_tags($_POST["etc"]))
if not using this minimal security, your php site gone easy-hacked place.

I do the anti hacking in the functions...

i believe its to change
PHP:
($_POST["password"] != $_POST["password2"])
to
PHP:
($_POST["password"] == $_POST["password2"])

Its suppose to be that way != is if they do not match, If they dont match then its going to display "Pass***** did not match"
 
<input type="image" src="" value="Register">

Should be

<input type="image" src="" name="Register">

As it is your $_POST['Register'] seems to be empty, thus it should always go to the first part. Didn't check your entire HTML though, bloody hell what a mess that is - try some indenting next time, and putting it in seperate files..
 
Back