PDA

View Full Version : PHP script won't display HTML.



BuaxDesigns
07-10-2008, 02:22 AM
Proberly a noobish error, but it's 3:20AM and I can't find it and it's really annoying me.


<?php
include("config.php");
if(isset($_POST['submit'])) {
$username = addslashes($_POST['username']);
$email = addslashes($_POST['email']);
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
if(empty($username) ||
empty($email) ||
empty($password1) ||
empty($password2)) {
die("You missed out a field!");

} else {

if($password1 != $password2) {

die("Your passwords did not match.");

} else {

$junk = array('¬','`','!','\"','£','$','%','^','&','*','(',')','_','-','+','=','[',']','{','}',';',':','@','\'','#','~','<','>',',','.','/','?','\\','|',' ');

$new_un = str_replace($junk,"",$username);

if($new_un < $username) {

die("Your username contained invalid characters.");

} else {

$pw_len = strlen($password1);

if($pw_len < 6) {

die("Your password is too short. It needs to be 6 or more characters.");

} else {

$istaken = mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `username`='" . $username . "'"));

if($istaken >= 1) {

die("That username is already being used.");

} else {

$istaken = mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `email`='" . $email . "'"));

if($istaken >= 1) {

die("That email is already being used.");

} else {

$password = md5($password1);

$create = mysql_query("
INSERT INTO `users` (
`id`,
`username`,
`password`,
`email`,
) VALUES (
NULL,
'" . $username . "',
'" . $password . "',
'" . $email . "'
);
");

if(!$create) {

die("There was a problem creating the user.");

} else {

die("You were registered successfully. Click <a href='login.php'>here</a> to login.");

}

}

}

}

}

}

}

?>
<form id="register" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">

Username:<br />
<input type="text" name="username" /><br /><br />

Email:<br />
<input type="text" name="email" /><br /><br />

Password:<br />
<input type="password1" name="password1" /><br /><br />

Confirm Password:<br />
<input type="password2" name="password2" /><br /><br />

<input type="submit" name="submit" value="Register" />

</form>
<?php

}

?>

It's a register script by the way. :) Incase you didn't know :/

BuaxDesigns
07-10-2008, 11:54 AM
I cant my posts yet; but I've fixed the error.

Want to hide these adverts? Register an account for free!