Jump to content

Multipul Issues -- Register Script


timecatcher

Recommended Posts

Hello, im having a few issues that I can't think how to solve concerning my register script.

 

Im getting the error password empty before I get a username empty error. I don't fully understand why this is.

 

My second issue is im not sure how to convert the three date variables into a birthday field in my database.

 

The last issue I think is the fact that I have to take into consideration those born in leap years since clearly february 29th doesn't always exist.

 

Hope this makes sense, and someone could shed some light on this for me.

 

 

Thanks. Here is the web address for the script: http://kurukolands.co.uk/Register.php and the script itself:

 

 

 

 

<?php
//Connects to the included file, (connectionfile.php) to allow database to be accessed.

//If statement checking that everything is in order and the user can then be logged in.
		if(isset($username) && isset($password))
			{
//Cookie sending information goes here. (Cookies cannot be sent after the header, only accessed.)
setcookie(username, $username);
setcookie(password, $password);
			}
//Checks all the information sent to the database for errors, or issues.
		if(isset($_POST['submit']))
			{
//Setting the strings.
		$username = $_POST['username'];
		$password = $_POST['password'];
		$password1 = $_POST['password1'];
		$firstname = $_POST['fname'];
		$lastname = $_POST['lastname'];
		$email = $_POST['email'];
		$birthyear = $_POST['birthyear'];
		$birthmonth = $_POST['birthmonth'];
		$birthday = $_POST['birthday'];
//Username checks.
				if(empty($username))
					{
					$error = "<li>Please enter a username.</li>";
					}
					elseif(strlen($username) < 3)
						{
						$error = "<li>Please choose a username longer than 3 characters.</li>";
						}
						//Remeber next time to use forward slash. And the [] thingys.
						elseif(preg_match("/^([a-zA-Z0-9_.-])+$/" , $username) == FALSE)
							{
							$error = "<li>Your username can only contain these characters: A-Za-z0-9_</li>";
							}
//Add more words here to make the profanity filter more strict.
		$filter = array('fuck', 'cunt', 'shit', 'dick', 'nigger');
//Checks to see if any of the filtered words are found in the username and prints out an error if true.
							for($f = 0; $f < count($filter); $f++)
								{
//The 'i' at the end of preg-match, makes it an case-insensitive search.
								if(preg_match('/'.$filter[$f].'/i', $username) == TRUE)
									{
									$error = "<li>This website does not allow profanity, please select a cleaner username.</li>";
									}
								}

//Password checks.
//You can change the variable to 1 if you want stronger security.
		$securityvar = 1;
				if(empty($password))
					{
					$error = "<li>Please enter a password</li>";
					}
					elseif(empty($password1))
						{
						$error = "<li>You need to enter your confirmation password.</li>";
						}
						elseif(strlen($password) < 4)
							{
							$error = "<li>Please enter a longer password.</li>";
							}
				elseif($securityvar == 1)
					{
					if(preg_match("/[A-Z]/", $password) == FALSE)
						{
						$error = "<li>Please have a combination of Upper case, lower case, numbers and special characters please.</li>";
						}
					elseif(preg_match("/[0-9]/", $password) == FALSE)
						{
						$error = "<li>Please have a combination of Upper case, lower case, numbers and special characters please.</li>";
						}
					elseif(preg_match("/[~!@#$%^&*]/", $password) == FALSE)
						{
						$error = "<li>Please have a combination of Upper case, lower case, numbers and special characters please.</li>";
						}
					elseif(preg_match("/[a-z]/", $password) == FALSE)
						{
						$error = "<li>Please have a combination of Upper case, lower case, numbers and special characters please.</li>";
						}	
					}
//E-mail checks.
//Birthdate checks.
			}
//Cleaning function used to make it easier to keep from SQL injects.
		function cleandb($clean)
			{
			mysql_real_escape_string(html_entities($clean));
			}
//All the database information gets stored here, generally before any HTML output is used.
//HTML FORM, this asks for all the data needed from the user.
echo"Welcome to PETSITENAME! You can begin your journey by registering below.<br />";
	echo"Please make sure you are over the age of 13 before registering to this website. <br />";
		echo"<b>COPPA laws are respected.</b> <br />";
			echo<<<echo
	Please enter your first name:<form method="post" action"><input type="text" name="fname">
	<br />
	Please enter your last name: <input type="text" name="lname">
	<br />

	Please select your real birth date:
		Year:
		<select name="birthyear">
echo;
//The date("y") part provides just the year from the date function.
		$currentYear = date("Y");
		for($by = $currentYear; $by>=1900; $by--)
			{
			echo<<<echo
			<option value="$by">$by</option>
echo;
			}
			//$dom = days of month.
		echo<<<echo
		</select>
		Day:
		<select name="birthday">
echo;
		$dom = 31;
		for($bd = $dom; $bd>=1; $bd--)
			{
			echo<<<echo
			<option value="$bd">$bd</option>
echo;
			}
		echo<<<echo
		</select>
		Month:
		<select name="birthmonth">
echo;
//Names of the months.
		$month = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
//Echoing out each month in turn.
		foreach($month as $month1)
			{
			echo<<<echo
			<option value="$month1">$month1</option>
echo;
			}
		echo<<<echo
		</select>
		<br />
		Please select your country:
		<select name="country">
echo;
//The list of countries, Judd I got this offline because I don't think my geography is that good .
			$countries = array(
	"Afghanistan",
	"Albania",
	"Algeria",
	"Andorra",
	"Angola",
	"Antigua and Barbuda",
	"Argentina",
	"Armenia",
	"Australia",
	"Austria",
	"Azerbaijan",
	"Bahamas",
	"Bahrain",
	"Bangladesh",
	"Barbados",
	"Belarus",
	"Belgium",
	"Belize",
	"Benin",
	"Bhutan",
	"Bolivia",
	"Bosnia and Herzegovina",
	"Botswana",
	"Brazil",
	"Brunei",
	"Bulgaria",
	"Burkina Faso",
	"Burundi",
	"Cambodia",
	"Cameroon",
	"Canada",
	"Cape Verde",
	"Central African Republic",
	"Chad",
	"Chile",
	"China",
	"Colombi",
	"Comoros",
	"Congo (Brazzaville)",
	"Congo",
	"Costa Rica",
	"Cote d'Ivoire",
	"Croatia",
	"Cuba",
	"Cyprus",
	"Czech Republic",
	"Denmark",
	"Djibouti",
	"Dominica",
	"Dominican Republic",
	"East Timor (Timor Timur)",
	"Ecuador",
	"Egypt",
	"El Salvador",
	"Equatorial Guinea",
	"Eritrea",
	"Estonia",
	"Ethiopia",
	"Fiji",
	"Finland",
	"France",
	"Gabon",
	"Gambia, The",
	"Georgia",
	"Germany",
	"Ghana",
	"Greece",
	"Grenada",
	"Guatemala",
	"Guinea",
	"Guinea-Bissau",
	"Guyana",
	"Haiti",
	"Honduras",
	"Hungary",
	"Iceland",
	"India",
	"Indonesia",
	"Iran",
	"Iraq",
	"Ireland",
	"Israel",
	"Italy",
	"Jamaica",
	"Japan",
	"Jordan",
	"Kazakhstan",
	"Kenya",
	"Kiribati",
	"Korea, North",
	"Korea, South",
	"Kuwait",
	"Kyrgyzstan",
	"Laos",
	"Latvia",
	"Lebanon",
	"Lesotho",
	"Liberia",
	"Libya",
	"Liechtenstein",
	"Lithuania",
	"Luxembourg",
	"Macedonia",
	"Madagascar",
	"Malawi",
	"Malaysia",
	"Maldives",
	"Mali",
	"Malta",
	"Marshall Islands",
	"Mauritania",
	"Mauritius",
	"Mexico",
	"Micronesia",
	"Moldova",
	"Monaco",
	"Mongolia",
	"Morocco",
	"Mozambique",
	"Myanmar",
	"Namibia",
	"Nauru",
	"Nepa",
	"Netherlands",
	"New Zealand",
	"Nicaragua",
	"Niger",
	"Nigeria",
	"Norway",
	"Oman",
	"Pakistan",
	"Palau",
	"Panama",
	"Papua New Guinea",
	"Paraguay",
	"Peru",
	"Philippines",
	"Poland",
	"Portugal",
	"Qatar",
	"Romania",
	"Russia",
	"Rwanda",
	"Saint Kitts and Nevis",
	"Saint Lucia",
	"Saint Vincent",
	"Samoa",
	"San Marino",
	"Sao Tome and Principe",
	"Saudi Arabia",
	"Senegal",
	"Serbia and Montenegro",
	"Seychelles",
	"Sierra Leone",
	"Singapore",
	"Slovakia",
	"Slovenia",
	"Solomon Islands",
	"Somalia",
	"South Africa",
	"Spain",
	"Sri Lanka",
	"Sudan",
	"Suriname",
	"Swaziland",
	"Sweden",
	"Switzerland",
	"Syria",
	"Taiwan",
	"Tajikistan",
	"Tanzania",
	"Thailand",
	"Togo",
	"Tonga",
	"Trinidad and Tobago",
	"Tunisia",
	"Turkey",
	"Turkmenistan",
	"Tuvalu",
	"Uganda",
	"Ukraine",
	"United Arab Emirates",
	"United Kingdom",
	"United States",
	"Uruguay",
	"Uzbekistan",
	"Vanuatu",
	"Vatican City",
	"Venezuela",
	"Vietnam",
	"Yemen",
	"Zambia",
	"Zimbabwe"
);
		foreach($countries as $countries1)
			{
			echo<<<echo
			<option value="$countries1">$countries1</option>
echo;
			}
		echo<<<echo
		</select>

	<br />
	Please enter your e-mail address:

		<input type="text" name="email">

	<br />

	Please enter your desired username:

		<input type="text" name="username">

	<br />

	Please enter your desired password:

		<input type="password" name="password">
	<br />

	Confirm your password choice:

		<input type="password" name="password1">
	<br />
	<input type="submit" name="submit" value="Submit">

	</form>
echo;

//The user is informed that there are either errors, or there registration has been successful.
	if(isset($error) && isset($_POST['submit']))
		{
		//This echo's out the error's that have been found in a list.
		echo "<center>$error</center>";
		}
		elseif(isset($_['submit']) && !isset($error))
			{
			echo "Congratulations! You have now been signed up to PETSITE!";
			}
?>
<html>
<title>
Register -- PETSITENAME
</title>
</html>

Link to comment
Share on other sites

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.