Jump to content


Account system not working


5 replies to this topic

#1 Wavedude

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 30 January 2009 - 01:16 AM

The PHP pages are not showing up on the site:

www.emptypageband.com/members/index.php

The server has the PHP and Mysql system on it and everything. It all should work but its not showing the PHP text at all. Whats wrong? And why are all the PHP pages like this?

#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 30 January 2009 - 02:34 AM

because somewhere on the page there is most likely a parse error in the script, i.e. a mistake has been made with the code and the script can't be passed.

Either turn on error reporting for that page to see the error or post the code you have written here so we can take a look and help fix it.

Matt

#3 Wavedude

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 30 January 2009 - 04:40 PM

<?php

session_start(); // start the session

require_once("data.php"); //include..



if(empty($_SESSION['username'])){

//check if user is not logged in



$act = htmlspecialchars(mysql_real_escape_string($_GET['act']));

// security hoo-haa



if($act == 'reg'){

// if we've attempted to start the registration process...

// lets set the variables

$username = htmlspecialchars(mysql_real_escape_string($_POST['username'])); // username...

$username = strtolower($username); // lets make it lower cased so username like fRIiKs would be transformed to friiks

$password = htmlspecialchars(mysql_real_escape_string($_POST['password'])); // password(s)

$passwordCheck = htmlspecialchars(mysql_real_escape_string($_POST['passwordCheck']));

$email = htmlspecialchars(mysql_real_escape_string($_POST['email'])); // E-mail



$checkUsername = mysql_num_rows(mysql_query("SELECT `id` FROM `users` WHERE `username`='".$username."' LIMIT 1"));

// check if username not taken

$emailCheck = mysql_num_rows(mysql_query("SELECT `id` FROM `users` WHERE `email`='".$email."' LIMIT 1"));

// check if E-mail not taken



if($checkUsername < 1 && $emailCheck < 1 && !empty($password) && !empty($username) && $password == $passwordCheck && strlen($username) < 18 && strlen($password) < 32){

// if everything's fine lets continue with the registration process



$hash = substr(md5(mt_rand(0000000,999999)."somethingForNothingRawr!"),0,25);

// create random, 25 character long hash

$password = sha1($password.$hash);

// create password



$lastId = mysql_fetch_array(mysql_query("SELECT `userId` FROM `users` ORDER BY `id` DESC LIMIT 1"));

$myId = $lastId['userId']+1;

// Get the last user id in the database and create the current users id



if(mysql_query("INSERT INTO `users` (`id`, `userId`, `userLevel`, `username`, `password`, `email`, `registered`, `avatar`, `randString`) VALUES ('NULL','".$myId."','1','".$username."','".$password."','".$email."','".time()."','','".$hash."')")){

// If the user data is inserted into the DB return success!

header("Location:register.php?act=success");

}else{

// if not, return error...

header("Location:register.php?act=err7");

}



}else{

// if something's wrong above let's check out what IS wrong and return an error!

if($checkUsername > 0){

header("Location:register.php?act=err0");

}

if($emailCheck > 0){

header("Location:register.php?act=err1");

}

if(empty($password)){

header("Location:register.php?act=err2");

}

if(empty($username)){

header("Location:register.php?act=err3");

}

if($password != $passwordCheck){

header("Location:register.php?act=err4");

}

if(strlen($username) > 18){

header("Location:register.php?act=err5");

}

if(strlen($password) > 32){

header("Location:register.php?act=err6");

}

}



}





$errors = array(

"0" => "Username already taken!",

"1" => "This E-mail is already used!",

"2" => "Password field must be filled!",

"3" => "Username field must be filled!",

"4" => "Passwords you entered didn't match!",

"5" => "Username is longer than 18 characters",

"6" => "Password is longer than 32 characters",

"7" => "There was an error while inserting data into database!<br />Please try again later!"

);

// lets create error reports...



if($act == "success"){

?>

<span style="color:green;font-weight:bold">Registration was successful, you may log in <a href="index.php">here</a></span>

<?

}else if(ereg('err',$act) > 0){

// if $act variable contains "err" then lets get the number of error and output the error!

?>

<span style="color:red;font-weight:bold"><?php echo $errors[substr($act,3)]; ?></span>

<?php

}



?>

<form action="register.php?act=reg" method="post" >

<table>

<tr><td>Username:</td><td><input type='text' name='username' maxlength='18' /></td></tr>

<tr><td>Password:</td><td><input type='password' name='password' maxlength='32' /></td></tr>

<tr><td>Password Again:</td><td><input type='password' name='passwordCheck' maxlength='32' /></td></tr>

<tr><td>E-Mail:</td><td><input type='text' name='email' /></td></tr>

<tr><td><input type='submit' value='Register' /></td></tr>

</table>

</form>



<?

}else{

// if user's logged in return the user to index

header("Location:index.php");

}



?>

Thats the Register code. All other codes work except for this one. When Register.php is clicked it shows a blank page.

In the server PHP says there's an error on line 227. But 227 is the very end on the script.

Bumping this. Hurry up and help, someone.

Edited by rc69, 31 January 2009 - 01:59 PM.


#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 31 January 2009 - 02:02 PM

1. Don't bump, this is the second post from the top. People know it's here.
2. Don't demand that people help you, it's not very enouraging.
3. Please provide the exact error PHP gave you. Line numbers are useful, but don't do much if we don't know what to look for (if i had to guess though, you are probably missing a '}' somewhere).

Edited by rc69, 31 January 2009 - 02:03 PM.


#5 Wavedude

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 31 January 2009 - 08:38 PM

Ok the errors gone now. Sorry, but its realy slow to get a reply back on this forum.

Now I have a different problem. When Im trying to register an account, the register.php page just refreshes. Why is this?

#6 023-jimmy

    Young Padawan

  • Members
  • Pip
  • 44 posts

Posted 01 February 2009 - 01:09 PM

This is because the <form> object is directing to the register page.

<form action="register.php?act=reg" method="post" >

Look at the action attribute. The link given there is where you will be directed to after you submitted the form.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users