I am trying to put a signup.php section on my website. The script dies somewhere in the php code, and i've been trying to figure it out for hours with no luck.
The script dies somewhere in here because when i throw this in the file and ftp it to the server and run it, the page comes back blank.
and here is the form in the body sectionPHP Code:<?php
include_once("scripts/connect_to_mysql.php");
$message ='';
if(isset($_POST['username'])){
$username = $_POST['username'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
//error handling
if((!$username)||(!$fname)||(!$lname)||(!$email)||(!$pass1)||(!$pass2)){
$message='Please insert all fields into the form below.';
}else{
if($pass1 != $pass2){
$message ='Your password fields do not match.';
}else{
//securing the values of the variables
$username = preg_replace("#[^0-9a-z]#i","",$username);
$fname = preg_replace("#[^0-9a-z]#i","",$fname);
$lname = preg_replace("#[^0-9a-z]#i","",$lname);
$pass1 = sha($pass1);
$email = mysql_real_escape_string($email);
//check duplicates
$user_query = mysql_query("SELECT username FROM members WHERE username='$username' LIMIT 1")or die("Could not check username");
$count_username = mysql_num_rows($user_query);
$user_query = mysql_query("SELECT email FROM members WHERE email='$email' LIMIT 1")or die("Could not check Email");
$count_email = mysql_num_rows($email_query);
if($count_username > 0){
$message ='Your username already exists.';
}else if($count_email > 0){
$message ='Your email already exists.';
}else{
// insert users
$query = mysql_query("INSERT INTO members (username, fname, lname, email, password, lastlogin, accounttype, emailactivated, joindate) VALUES('$username', '$fname', '$lname', '$email', '$password', '', '', '', now())")or die("Could not insert data.");
$member_id = mysql_insert_id();
mkdir("users/$member_id",0755);
$message ='You have now been registered.';
}
}
?>
Code:<div> Register to my site by filling in the fields below. <p><?php print("$message");?></p> <form action="register2.php" method="post"> <input type="text" name="username" placeholder="Username"/><br /> <input type="text" name="fname" placeholder="First Name"/><br /> <input type="text" name="lname" placeholder="Last Name"/><br /> <input type="text" name="email" placeholder="Email Address"/><br /> <input type="password" name="pass1" placeholder="Password"/><br /> <input type="password" name="pass2" placeholder="Validate your password"/><br /> <input type="submit" value="Register" /> </form> </div>


Reply With Quote

Bookmarks