Jump to content

Recommended Posts

  • Replies 100
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Well, in all reality you could put it all in one page if you wanted... I have my entire site and a forum on one page...

 

You should get an editor that offers syntax highlighting. I use geany and phpdesigner...

 

You need the form in signup.php so as to sign your users up.

 

You then need to place the rest in check.php

Im pretty sure I slaughtered this, sorry for being a bother, lol

 

 

This is what I got in signup.php ... When I add that stuff from Reply #23, It shows up when I view signup.php so I put it in check.php

 

This is signup.php:

 


<html>
<head>
	<title>Sign Up</title>
</head>

<body>

<form action="check.php" method="post">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
Verify Password: <input type="password" name="varpassword" /><br />
E-mail: <input type="text" name="email" /><br />
<input type="submit" value="Sign Up" />
</form>





</body>
</html>

 

 

And this is in check.php .. I did what you told me to in the comments, but I probably messed that up.

 

 


<?php
		echo "<form action=/"check.php/" method=/"post/">"
			if ($_SESSION['short_username'] == TRUE)
			{
				echo "Your username was too short!<br />";
				$_SESSION['short_username'] = FALSE;
			}

			if ($_SESSION['bad_username'] == TRUE)
			{
				echo "Usernames may only contain alphanumeric characters, dashes (-) and underscores (_)<br />";
				$_SESSION['bad_username'] = FALSE;
			}
			echo "Username: <input type=/"text/" name=/"username/" /><br />"

			if ($_SESSION['short_password'] == TRUE)
			{
				echo "Your password was too short!<br />";
				$_SESSION['short_password'] = FALSE;
			}

			if ($_SESSION['bad_password'] == TRUE)
			{
				echo "Passwords may only contain alphanumeric characters<br />";
				$_SESSION['bad_password'] = FALSE;
			}
			echo "Password: <input type=/"password/" name=/"password/" /><br />

			if ($_SESSION['match_password'] == TRUE)
			{
				echo "Your passwords did not match!<br />";
				$_SESSION['match_password'] = FALSE;
			}
			echo "Verify Password: <input type=/"password/" name=/"varpassword/" /><br />"

			if ($_SESSION['bad_email'] == TRUE)
			{
				echo "You have entered an invalid E-mail address<br />";
				$_SESSION['bad_email'] = FALSE;
			}
			echo "E-mail: <input type=/"text/" name=/"email/" /><br />"
			<input type=/"submit/" value=/"Sign Up/" />
		</form>


if (strlen($_POST['username']) < 4)
{

if (strlen($_POST['password']) < 6)
{

if (strlen($_POST['email']) < 
{


//There username contains less than 4 characters



//Set a session variable so that you can tell the user how they screwed up



$_SESSION['short_username'] = TRUE;
$_SESSION['short_password'] = TRUE;
$_SESSION['bad_email'] = TRUE;
$_SESSION['match_password'] = TRUE;



//Tell the script that something went wrong



$pass = FALSE;
{
//Do that for all the fields.
//You should change the "4" to an "8" for the email address.
//No email address will have less than 8 characters!

if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username']))
{
   
if (preg_match("/[^a-zA-Z0-9]/", $_POST['password']))
{

if (preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email'])) 
{	

//There username contains invalid characters



//They me be trying to hack you...



//Set a session variable so that you can tell the user how they screwed up



$_SESSION['bad_username'] = TRUE;
$_SESSION['bad_password'] = TRUE;
$_SESSION['match_password'] = TRUE;
$_SESSION['bad_email'] = TRUE;


//Tell the script that something went wrong



$pass = FALSE;
}
//Again, do that for all the fields.
//You should use preg_match("/[^a-zA-Z0-9]/", $_POST['password']) for the password.
//You should use preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email']) for the email!

//I do this part to make sure they don't do anything stupid.
//Like if they put "2+2" for the password and "4" for the varpassword,
//Then this would stop that from proving true!

$password = md5($_POST['password']);
$varpassword = md5($_POST['varpassword']);
if ($password != $varpassword)
{



//There passwords did not match



//Set a session variable so that you can tell the user how they screwed up



$_SESSION['match_password'] = TRUE;



//Tell the script that something went wrong



$pass = FALSE;
}

if ($pass == FALSE)
{



//They failed the exam!



//For some reason they have failed or check system.



//You will need to send the back to fix the problem before we continue



echo "<meta http-equiv=/"refresh/" content=/"1;url=signup.php/">";



//I like to kill the script at this point.



die();
}
else
{



//Hey they past our test!



//Looking at all this, I don't know how! lol



//You can now change their password into something unreadable.



//I do it again to make sure nothing happened to it on the way...



$password = md5($_POST['password']);



//Now that you have all their info, you can put them into the database



//Connect to the database



$connect = mysql_connect('localhost',$username,$password) or die(mysql_error());



//Select your database



mysql_select_db($database) or die(mysql_error());



//Insert new user



$query = mysql_query("INSERT INTO users ('username', 'password', 'email')
          VALUES ($_POST['username'], $password, $_POST['email'])") or die(mysql_error());



//Close mysql



mysql_close();



//Now they have an account!
}











?>

 

 

Can you just give me a little step-by-step and fill in what I filled in wrong?, lol

 

If possible, just give me exactly what I need so I can copy and paste it.

 

Along with signup.php and check.php, should I have any other files in my root directory?

Well, Here you go. Try it and see if it works...

 

signup.php

<html>
<head>
	<title>Sign Up</title>
</head>

<body>
	<?php
		echo "<form action=/"check.php/" method=/"post/">"
			if ($_SESSION['short_username'] == TRUE)
			{
				echo "Your username was too short!<br />";
				$_SESSION['short_username'] = FALSE;
			}

			if ($_SESSION['bad_username'] == TRUE)
			{
				echo "Usernames may only contain alphanumeric characters, dashes (-) and underscores (_)<br />";
				$_SESSION['bad_username'] = FALSE;
			}
			echo "Username: <input type=/"text/" name=/"username/" /><br />"

			if ($_SESSION['short_password'] == TRUE)
			{
				echo "Your password was too short!<br />";
				$_SESSION['short_password'] = FALSE;
			}

			if ($_SESSION['bad_password'] == TRUE)
			{
				echo "Passwords may only contain alphanumeric characters<br />";
				$_SESSION['bad_password'] = FALSE;
			}
			echo "Password: <input type=/"password/" name=/"password/" /><br />";

			if ($_SESSION['match_password'] == TRUE)
			{
				echo "Your passwords did not match!<br />";
				$_SESSION['match_password'] = FALSE;
			}
			echo "Verify Password: <input type=/"password/" name=/"varpassword/" /><br />"

			if ($_SESSION['bad_email'] == TRUE)
			{
				echo "You have entered an invalid E-mail address<br />";
				$_SESSION['bad_email'] = FALSE;
			}
			echo "E-mail: <input type=/"text/" name=/"email/" /><br />"
			<input type=/"submit/" value=/"Sign Up/" />
		</form>
	?>
</body>
</html>

 

 

 

check.php

<?php
//Database Information
//Username?
$database_username = "forum";

//Your password?
$database_password = "password";

//The name of the database you are trying to connect to
$database_database = "users";


//Did the user enter a username?
if (strlen($_POST['username']) < 4)
{
	//There username contains less than 4 characters

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['short_username'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
{

//Did the user enter a password?
if (strlen($_POST['password']) < 4)
{
	//There password contains less than 4 characters

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['short_password'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
{


//Did the user enter a email adress?
if (strlen($_POST['email']) < 
{
	//There email contains less than 4 characters

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['bad_email'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
{



//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username']))
{
   		//Their username contains invalid characters
	//They me be trying to hack you...

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['bad_username'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
}

//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9]/", $_POST['password']))
{
   		//Their password contains invalid characters
	//They me be trying to hack you...

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['bad_password'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
}

//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email']))
{
   		//Their email contains invalid characters
	//They me be trying to hack you...

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['bad_email'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
}


//For added security, MD5 their passwords before you compare them
$md5_password = md5($_POST['password']);
$md5_varpassword = md5($_POST['varpassword']);

//For the usres benifit, make sure their passwords match
if ($md5_password != $md5_varpassword)
{
	//There passwords did not match

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['match_password'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
}


//If something went wrong, send the back to fix their mistakes
if ($pass == FALSE)
{
	//They failed the exam
	//For some reason they have failed or check system

	//You will need to send the back to fix the problem before we continue
	echo "<meta http-equiv=/"refresh/" content=/"1;url=signup.php/">";

	//I like to kill the script at this point.
	die();
}
else
{
	//They have entered all the required information
	//Their username, password, and email are acceptible


	//For the users pertection, you should always encypt their passwords
	$password = md5($_POST['password']);


	//You now have all their info, you may put them into the database

	//Connect to the database
	$connect = mysql_connect('localhost',$username,$password) or die(mysql_error());

	//Select your database
	mysql_select_db($database) or die(mysql_error());

	//Insert new user
	$query = mysql_query("INSERT INTO users ('username', 'password', 'email')
        	  VALUES ($_POST['username'], $password, $_POST['email'])") or die(mysql_error());

	//Close mysql
	mysql_close();


	//They are now signed up
	//Tell them that are now signed up
	echo "Congratulations, you are now signed up!";

	//Send them back to the home page
	echo "<meta http-equiv=/"refresh/" content=/"6;url=index.php/">";

	//Offer an optional link incase the transfer doesn't work
	echo "<a href=/"index.php/">If you are not transfered in 10 seconds, click here</a>";
}
?>

Do NOT use the code above. Use the one below. I have made a few modifications....

 

signup.php

<html>
<head>
	<title>Sign Up</title>
</head>

<body>
	<?php
		echo "<form action=/"check.php/" method=/"post/">";
			if ($_SESSION['short_username'] == TRUE)
			{
				echo "Your username was too short!<br />";
				$_SESSION['short_username'] = FALSE;
			}

			if ($_SESSION['bad_username'] == TRUE)
			{
				echo "Usernames may only contain alphanumeric characters, dashes (-) and underscores (_)<br />";
				$_SESSION['bad_username'] = FALSE;
			}
			echo "Username: <input type=/"text/" name=/"username/" /><br />";

			if ($_SESSION['short_password'] == TRUE)
			{
				echo "Your password was too short!<br />";
				$_SESSION['short_password'] = FALSE;
			}

			if ($_SESSION['bad_password'] == TRUE)
			{
				echo "Passwords may only contain alphanumeric characters<br />";
				$_SESSION['bad_password'] = FALSE;
			}
			echo "Password: <input type=/"password/" name=/"password/" /><br />";

			if ($_SESSION['match_password'] == TRUE)
			{
				echo "Your passwords did not match!<br />";
				$_SESSION['match_password'] = FALSE;
			}
			echo "Verify Password: <input type=/"password/" name=/"varpassword/" /><br />";

			if ($_SESSION['bad_email'] == TRUE)
			{
				echo "You have entered an invalid E-mail address<br />";
				$_SESSION['bad_email'] = FALSE;
			}
			echo "E-mail: <input type=/"text/" name=/"email/" /><br />";
			echo "<input type=/"submit/" value=/"Sign Up/" />";
		echo "</form>";
	?>
</body>
</html>

 

 

 

check.php

<?php
//Database Information
//Username?
$database_username = "username";

//Your password?
$database_password = "password";

//The name of the database you are trying to connect to
$database_database = "forum";


//Did the user enter a username?
if (strlen($_POST['username']) < 4)
{
	//There username contains less than 4 characters

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['short_username'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
{

//Did the user enter a password?
if (strlen($_POST['password']) < 4)
{
	//There password contains less than 4 characters

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['short_password'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
{


//Did the user enter a email address?
if (strlen($_POST['email']) < 
{
	//There email contains less than 4 characters

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['bad_email'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
{



//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username']))
{
   		//Their username contains invalid characters
	//They me be trying to hack you...

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['bad_username'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
}

//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9]/", $_POST['password']))
{
   		//Their password contains invalid characters
	//They me be trying to hack you...

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['bad_password'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
}

//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email']))
{
   		//Their email contains invalid characters
	//They me be trying to hack you...

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['bad_email'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
}


//For added security, MD5 their passwords before you compare them
$md5_password = md5($_POST['password']);
$md5_varpassword = md5($_POST['varpassword']);

//For the users benefit, make sure their passwords match
if ($md5_password != $md5_varpassword)
{
	//There passwords did not match

	//Set a session variable so that you can tell the user how they screwed up
	$_SESSION['match_password'] = TRUE;

	//Tell the script that something went wrong
	$pass = FALSE;
}


//If something went wrong, send them back to fix their mistakes
if ($pass == FALSE)
{
	//They failed the exam
	//For some reason they have failed or check system

	//You will need to send the back to fix the problem before we continue
	echo "<meta http-equiv=/"refresh/" content=/"1;url=signup.php/">";

	//I like to kill the script at this point.
	die();
}
else
{
	//They have entered all the required information
	//Their username, password, and email are acceptable


	//For the users protection, you should always encrypt their passwords
	$password = md5($_POST['password']);


	//You now have all their info, you may put them into the database

	//Connect to the database
	$connect = mysql_connect('localhost', $username, $password) or die(mysql_error());

	//Select your database
	mysql_select_db($database) or die(mysql_error());

	//Insert new user
	$query = mysql_query("INSERT INTO users ('username', 'password', 'email')
        	  VALUES ($_POST['username'], $password, $_POST['email'])") or die(mysql_error());

	//Close mysql
	mysql_close();


	//They are now signed up
	//Tell them that they are now signed up
	echo "Congratulations, you are now signed up!";

	//Send them back to the home page
	echo "<meta http-equiv=/"refresh/" content=/"6;url=index.php/">";

	//Offer an optional link in case the transfer doesn't work
	echo "<a href=/"index.php/">If you are not transfered in 10 seconds, click here</a>";
}
?>

Thanks alot man. Im suprised you've stayed with me so far and been so helpful  ;D

 

But still, there remains a problem. I did all that exactly, changed username to root and left the password blank since its running locally.

 

Problem is, when I view signup.php .. It just shows me some of the php code with a couple field boxes. I would really like to know whats causing this.

Something is definitely wrong because I just get a blank page  :'(

 

Don't "just run that page" ... unless you actually opened a browser and navigated to http://localhost/path/to/that/file  php files don't run when opened in isolation, they need to be run on a server.

Now I get this:

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampplite\htdocs\xampp\site\signup.php on line 8

 

 

I've tried removing characters and testing and it still wont work.

 

 

<html>

<head>

<title>Sign Up</title>

</head>

 

<body>

<?php

echo "<form action=/"check.php/" method=/"post/">";

if ($_SESSION['short_username'] == TRUE)

 

I was fixing codes fine, I tried googling this with no help:

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampplite\htdocs\xampp\site\check.php on line 141

 

(The 3rd line is line 141)

 

 

//Insert new user

$query = mysql_query("INSERT INTO users ('username', 'password', 'email')

VALUES ($_POST['username'], $password, $_POST['email'])") or die(mysql_error());

 

Replace that with this:

 

$username = $_POST['username'];
$email = $_POST['email'];

$query = mysql_query ("INSERT INTO `users` (username, password, email) VALUES ('$username', '$password', '$email'") OR DIE (mysql_error());

 

It should work.

Parse error: syntax error, unexpected $end in C:\xampplite\htdocs\xampp\site\check.php on line 161

 

 

 

That line is blank. And its after the ?>

 

Am I not closing a funtion?

 

This is the last chunk of lines:

 

//Insert new user

$username = $_POST['username'];

$email = $_POST['email'];

 

$query = mysql_query ("INSERT INTO `users` (username, password, email) VALUES ('$username', '$password', '$email'") OR DIE (mysql_error());

 

//Close mysql

mysql_close();

 

 

//They are now signed up

//Tell them that they are now signed up

echo "Congratulations, you are now signed up!";

 

//Send them back to the home page

echo '<meta http-equiv="refresh" content="6;url=index.php">';

 

//Offer an optional link in case the transfer doesn't work

echo '<a href="index.php">If you are not transfered in 10 seconds, click here</a>';

}

?>

 

 

This is the whole code:

 

(password is actually blank cause im running locally)

 

 


<?php
//Database Information
//Username?
$database_username = "root";

//Your password?
$database_password = "";

//The name of the database you are trying to connect to
$database_database = "members";


//Did the user enter a username?
if (strlen($_POST['username']) < 4)
{
//There username contains less than 4 characters

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['short_username'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
{

//Did the user enter a password?
if (strlen($_POST['password']) < 4)
{
//There password contains less than 4 characters

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['short_password'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
{


//Did the user enter a email address?
if (strlen($_POST['email']) < 
{
//There email contains less than 4 characters

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['bad_email'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
{



//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username']))
{
//Their username contains invalid characters
//They me be trying to hack you...

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['bad_username'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}

//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9]/", $_POST['password']))
{
//Their password contains invalid characters
//They me be trying to hack you...

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['bad_password'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}

//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email']))
{
//Their email contains invalid characters
//They me be trying to hack you...

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['bad_email'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}


//For added security, MD5 their passwords before you compare them
$md5_password = md5($_POST['password']);
$md5_varpassword = md5($_POST['varpassword']);

//For the users benefit, make sure their passwords match
if ($md5_password != $md5_varpassword)
{
//There passwords did not match

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['match_password'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}


//If something went wrong, send them back to fix their mistakes
if ($pass == FALSE)
{
//They failed the exam
//For some reason they have failed or check system

//You will need to send the back to fix the problem before we continue
echo '<meta http-equiv=/"refresh/" content=/"1;url=signup.php/">';

//I like to kill the script at this point.
die();
}
else
{
//They have entered all the required information
//Their username, password, and email are acceptable


//For the users protection, you should always encrypt their passwords
$password = md5($_POST['password']);


//You now have all their info, you may put them into the database

//Connect to the database
$connect = mysql_connect('localhost', $username, $password) or die(mysql_error());

//Select your database
mysql_select_db($database) or die(mysql_error());

//Insert new user
$username = $_POST['username'];
$email = $_POST['email'];

$query = mysql_query ("INSERT INTO `members` (username, password, email) VALUES ('$username', '$password', '$email'") OR DIE (mysql_error());

//Close mysql
mysql_close();

//They are now signed up
//Tell them that they are now signed up
echo "Congratulations, you are now signed up!";

//Send them back to the home page
echo '<meta http-equiv="refresh" content="6;url=index.php">';

//Offer an optional link in case the transfer doesn't work
echo '<a href="index.php">If you are not transfered in 10 seconds, click here</a>';
}

?>



Im starting to catch on little by little  ;D .. There were a bunch of { that shoulda been }

 

OK .. So I got the errors outta the way .. after entering some information and mismatchin passwords in the signup.php, it brings me to check.php but its blank.

 

The name of my database is main and I have the table members in there with 4 fields (username, password, email, id) .. Let me know if anything is wrong in the code about that. Thanks.

 

This is how my code looks now:

 


<?php
//Database Information
//Username?
$database_username = "root";

//Your password?
$database_password = "";

//The name of the database you are trying to connect to
$database_database = "main";


//Did the user enter a username?
if (strlen($_POST['username']) < 4)
{
//There username contains less than 4 characters

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['short_username'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}

//Did the user enter a password?
if (strlen($_POST['password']) < 4)
{
//There password contains less than 4 characters

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['short_password'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}


//Did the user enter a email address?
if (strlen($_POST['email']) < 
{
//There email contains less than 4 characters

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['bad_email'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}



//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username']))
{
//Their username contains invalid characters
//They me be trying to hack you...

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['bad_username'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}

//Make sure they aren't trying to hack you
if (preg_match("/[^a-zA-Z0-9]/", $_POST['password']))
{
//Their password contains invalid characters
//They me be trying to hack you...

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['bad_password'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}

//Make sure they aren't trying to hack you
if (preg_match("[^a-zA-Z0-9_-.@]", $_POST['email']))
{
//Their email contains invalid characters
//They me be trying to hack you...

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['bad_email'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}


//For added security, MD5 their passwords before you compare them
$md5_password = md5($_POST['password']);
$md5_varpassword = md5($_POST['varpassword']);

//For the users benefit, make sure their passwords match
if ($md5_password != $md5_varpassword)
{
//There passwords did not match

//Set a session variable so that you can tell the user how they screwed up
$_SESSION['match_password'] = TRUE;

//Tell the script that something went wrong
$pass = FALSE;
}


//If something went wrong, send them back to fix their mistakes
if ($pass == FALSE)
{
//They failed the exam
//For some reason they have failed or check system

//You will need to send the back to fix the problem before we continue
echo '<meta http-equiv=/"refresh/" content=/"1;url=signup.php/">';

//I like to kill the script at this point.
die();
}
else
{
//They have entered all the required information
//Their username, password, and email are acceptable


//For the users protection, you should always encrypt their passwords
$password = md5($_POST['password']);


//You now have all their info, you may put them into the database

//Connect to the database
$connect = mysql_connect('localhost', $username, $password) or die(mysql_error());

//Select your database
mysql_select_db($database) or die(mysql_error());

//Insert new user
$username = $_POST['username'];
$email = $_POST['email'];

$query = mysql_query ("INSERT INTO `members` (username, password, email) VALUES ('$username', '$password', '$email'") OR DIE (mysql_error());

//Close mysql
mysql_close();

//They are now signed up
//Tell them that they are now signed up
echo "Congratulations, you are now signed up!";

//Send them back to the home page
echo '<meta http-equiv="refresh" content="6;url=index.php">';

//Offer an optional link in case the transfer doesn't work
echo '<a href="index.php">If you are not transfered in 10 seconds, click here</a>';
}

?>

Wow, you sure do a lot when I'm gone!

 

Im starting to catch on little by little  ;D .. There were a bunch of { that shoulda been }

 

Sorry about, I copy and pasted the the if statement to make work easier, and it I guess it copyed the error with it...

 

 

OK .. So I got the errors outta the way .. after entering some information and mismatchin passwords in the signup.php, it brings me to check.php but its blank.

 

The name of my database is main and I have the table members in there with 4 fields (username, password, email, id) .. Let me know if anything is wrong in the code about that. Thanks.

 

I'm sorry for the trouble this has caused you! If my normal linux partition was up, I would have gave you the working script, instead of the one I just typed up in notepad...

 

I should also point out, I have never used the  /"  before, I thought for sure that would work...

 

Well, I will look this script over again and make sure that it is updated and hopefully you won't get any errors and it will work!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.