[PHP] Registration form
#1

This is a simple form that allows you to register for lastchaos, fill in the dbuser, dbpass, dbhost and db name and your all set.

also youll want to change the message for welcome to pyrexiastudios lastchaos to your own server name

 

"

"you should change register2.php to the same page the that the form is on

 

 

DEMO: 2

 

Features

 

anti sql inject

username limit 15 (like the lastchaos username limit)

password has to be more than 6 characters

all fields must be filled in to register

 

Working on

No spaces in username

Must have @ and atleast 1 . in your email

 

 

updated for 00211

<?php

echo "Register";

$dbuser = "root";
$dbpass = "";
$dbhost = "127.0.0.1";
$dbname = "lcep2";

//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_escape_string($str);
}

//form data
$submit = strip_tags(@$_POST [submit]) ;

$username = clean(strip_tags(@$_POST [username])) ;

$password = clean(strip_tags(@$_POST [password])) ;
$repeatpassword = clean(strip_tags(@$_POST [repeatpassword])) ;

$email = strip_tags(@$_POST [email]) ;
$date = date("Y-m-d") ;

if ($submit)
{

//check for existance
if ($username&&$password&&$repeatpassword&&$email)
{
//password match
if ($password==$repeatpassword)
{
//opens database
$msconn = mysql_connect($dbhost, $dbuser, $dbpass);
$db = mysql_select_db($dbname, $msconn);
mysql_query("set names UTF8");

//Check for duplicate login ID
if($username != ) {
$qry = "SELECT * FROM t_users WHERE a_username=$username";
$result = mysql_query($qry);
if($result) {
if(mysql_num_rows($result) > 0)
{
echo Username already in use.;
}

else
{
//username and email lengh
if (strlen($username)>15||strlen($email)>30)
{
echo "lengh of Username or Email is too long!";
}

else
{
//check password lengh
if (strlen($password)>15||strlen($password)<6)
{
echo "Password must be between 6 and 15 characters";
}
else
{
//register the user

//open database

$queryreg = mysql_query("INSERT INTO t_users VALUES (,$username,$password,1,0,0,$email,$date,)");

die("You are now registered for PyrexiaStudios LastChaos");

}

}

}
}
}
}
else
echo "Your Passwords do not match!";

}
else
echo "Please fill in all of the fields!";
}

?>

</pre>
<table width="296">
Username:
 
>
   
Password:
 

   
Repeat Password:
 

   
Email:
 
>
  

 

</table>
<br><br><b

 

[special Thanks to Max for help with anti sql injection]

#2
Thank u Syco. I test it later.. Wink

#3
your welcome

#4

What does this message mean?

 

Warning: date() [function.date]: It is not safe to rely on the systems timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected Europe/Paris for 2.0/DST instead in C:\Archivos de programa\xampp\htdocs\register2.php on line 30

#5
FFS guys if i dont gett a message tommora how to register t.t

#6

i dont understand. I Can copy the Code and add to a Homepage? but when i copy and paste, it doesnt work.

Can someone write a tutorial on how to get a account

#7
Bad PHP Code Register register2.php in not worked xD

#8
mee too not works... Help! ;P

#9

If u dont know how it works

PLZ dont make a Emu Server !!

#10
I know how it works because its another problem. Php code is (for me) ok.



Forum Jump:


Users browsing this thread: 1 Guest(s)