timecatcher Posted September 14, 2009 Share Posted September 14, 2009 Hey guys im trying to structure my website, now that I have started with a few of the scripts: <?php session_start(); //Connects to the included file, (connectionfile.php) to allow database to be accessed. require("../includes/config.php"); //Checks all the information sent to the database for errors, or issues. if(isset($_POST['submit'])) { //Setting the strings. $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $password1 = mysql_real_escape_string($_POST['password1']); $firstname = mysql_real_escape_string($_POST['fname']); $lastname = mysql_real_escape_string($_POST['lname']); $email = mysql_real_escape_string($_POST['email']); $email1 = mysql_real_escape_string($_POST['email1']); $birthyear = mysql_real_escape_string($_POST['birthyear']); $birthmonth = mysql_real_escape_string($_POST['birthmonth']); $birthday = mysql_real_escape_string($_POST['birthday']); $ace = $_POST['ace']; $accesscode = 125826841397; //Setting sessions to save information on accidental entry. $_SESSION['username'] = $username; $_SESSION['firstname'] = $firstname; $_SESSION['lastname'] = $lastname; $_SESSION['email'] = $email; //Access code checks. if($ace != $accesscode) { $error .= "<li>Im sorry you need to enter the right access code on signup, this will change after Kuruko Lands is in BETA.</li>"; } if($birthyear > date(Y)-13) { echo "Im sorry but your are not of legal age to become a member of kurukolands.co.uk <a href=\"http://google.co.uk\">Google</a>"; die(); } if(empty($username)) { $error .= "<li>Please enter a username.</li>"; } //Checks that the username doesn't already exist within the database. $query = mysql_query("SELECT * FROM users WHERE username='".$username."'"); if(mysql_num_rows($query) > 0) { $error .= "<li>Sorry that username is already taken, please create another one.</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($password != $password1) { $error .= "<li>Please enter the correct confirmation 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.</li>"; } elseif(preg_match("/[0-9]/", $password) == FALSE) { $error .= "<li>Please have a combination of Upper case, lower case, numbers and special characters.</li>"; } elseif(preg_match("/[~!@#$%^&*-]/", $password) == FALSE) { $error .= "<li>Please have a combination of Upper case, lower case, numbers and special characters.</li>"; } elseif(preg_match("/[a-z]/", $password) == FALSE) { $error .= "<li>Please have a combination of Upper case, lower case, numbers and special characters.</li>"; } } //E-mail checks. //Change to 0 to remove the e-mail confirmation check. if(preg_match("/[@]/", $email) == FALSE) { $error .= "<li>Please choose a valid e-mail address.</li>"; } elseif(preg_match("/[.]/", $email) == FALSE) { $error .= "<li>Please choose a valid e-mail address.</li>"; } $query = mysql_query("SELECT * FROM users WHERE email='".$email."'"); if(mysql_num_rows($query) > 0) { $error .= "<li>Sorry that email is already taken, please create another one.</li>"; } elseif($email1 != $email) { $error .= "<li>Please enter the same e-mail address in the confirmation box.</li>"; } //Birthdate checks. //This assigns each month a numeric value. if($birthmonth == "Jan") { $birthmonth = 1; } elseif($birthmonth == "Feb") { $birthmonth = 2; } elseif($birthmonth == "Mar") { $birthmonth = 3; } elseif($birthmonth == "Apr") { $birthmonth = 4; } elseif($birthmonth == "May") { $birthmonth = 5; } elseif($birthmonth == "Jun") { $birthmonth = 6; } elseif($birthmonth == "Jul") { $birthmonth = 7; } elseif($birthmonth == "Aug") { $birthmonth = 8; } elseif($birthmonth == "Sep") { $birthmonth = 9; } elseif($birthmonth == "Oct") { $birthmonth = 10; } elseif($birthmonth == "Nov") { $birthmonth = 11; } elseif($birthmonth == "Dec") { $birthmonth = 12; } //This piece of code equates for leap years and feburary 29th. if($birthmonth == 2 && $birthday > 29) { $error .= "<li>Please enter a valid birthday, i.e not 30th February.</li>"; } if($birthmonth == 4 && $birthday > 30) { $error .= "<li>Please enter a valid birthday, i.e not 30th February.</li>"; } if($birthmonth == 6 && $birthday > 30) { $error .= "<li>Please enter a valid birthday, i.e not 30th February.</li>"; } if($birthmonth == 8 && $birthday > 30) { $error .= "<li>Please enter a valid birthday, i.e not 30th February.</li>"; } if($birthmonth == 10 && $birthday > 30) { $error .= "<li>Please enter a valid birthday, i.e not 30th February.</li>"; } if($birthmonth == 12 && $birthday > 30) { $error .= "<li>Please enter a valid birthday, i.e not 30th February.</li>"; } } //DATABASE INFORMATION GOES BELOW!!! //All the database information gets stored here, generally before any HTML output is used. if(!isset($error) && isset($_POST['submit'])) { $username = mysql_real_escape_string($username); $password = mysql_real_escape_string(md5($password)); $firstname = mysql_real_escape_string($firstname); $lastname = mysql_real_escape_string($lastname); $email = mysql_real_escape_string($email); $birthday = mysql_real_escape_string($birthday); $birthmonth = mysql_real_escape_string($birthmonth); $birthyear = mysql_real_escape_string($birthyear); $points = 0; mysql_query("INSERT INTO users (username, password, firstname, lastname, email, birthday, birthmonth, birthyear, points) VALUES ('$username', '$password', '$firstname', '$lastname', '$email', '$birthday', '$birthmonth', '$birthyear', '$points') ") or die(mysql_error()); $cookie = 1; } //HTML FORM, this asks for all the data needed from the user. echo "$banner"; echo "$layout<div id='content'>"; echo"Welcome to Kuruko Lands! 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 />"; if(isset($_SESSION['firstname'])) { $a = $_SESSION['firstname']; } if(isset($_SESSION['lastname'])) { $b = $_SESSION['lastname']; } if(isset($_SESSION['email'])) { $c = $_SESSION['email']; } if(isset($_SESSION['username'])) { $d = $_SESSION['username']; } echo<<<echo Please enter your first name: <br /> <form method="post" action"><input type="text" name="fname" value="$a"> <br /> Please enter your last name: <br /> <input type="text" name="lname" value="$b"> <br /> Please select your real birth date: <br /> 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: <br /> <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: (Must contain '@' and '.') <br /> <input type="text" name="email" value="$c"> <br /> Please confirm your e-mail address: <br /> <input type="text" name="email1" value="$c"> <br /> Please enter your desired username: (Only A-Za-z0-9) <br /> <input type="text" name="username" value="$d"> <br /> Please enter your desired password: (Must include upper case, lower case, special characters and numbers) <br /> <input type="password" name="password"> <br /> Confirm your password choice: <br /> <input type="password" name="password1"> <br /> Please enter the Access code: <br /> <input type="text" name="ace"> <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><ul>$error</ul></center>"; } elseif(isset($_POST['submit']) && !isset($error)) { //Welcome message. echo "Welcome to Kuruko Lands! You journey awaits you."; } echo "</div>"; ?> <html> <title> Register -- Kuruko Lands </title> </html> Heres my register script which works however the banner doesn't appear when it should. Its linked to my config script: <?php //Template information. //Connect information. mysql_connect("localhost", "********", "************") or die(mysql_error()); mysql_select_db("*******") or die(mysql_error()); //The string containing the layout include string. $layout = "<link rel='stylesheet' href='../includes/template/layout.css' type='text/css'>"; $banner = "<link rel='stylesheet' href='../includes/template/layout.css' type='text/css'><div id='banner'></div>" ?> Then ofcourse theres the css file: #banner{ left: 0px; top: 0px; width: 1180px; height: 123px; color: #000000; postion: absolute; background-image: url(images/template/banner.png); } #nav{ left: 0px; top: 123px; width: 150px; height: 300px; color: #000000; postion: absolute; background-image: url(../images/template/navbar.png); } #content{ top: 210px; left: 170px; height: 1500px; width: 1050px; color: #000000; position: absolute; overflow: auto; } #profile{ left: 0px; top: 140px; width: 150px; height: 75px; color: #000000; position: absolute; background-image: url(../images/profilebackground.gif); } Just so you know i've tryed the images with the ../ and without, doesn't seem to make a difference, and im now asking you guys just incase you might know a way I can get the banner to appear please , thanks! Link to comment https://forums.phpfreaks.com/topic/174242-solved-phpcss-issue/ Share on other sites More sharing options...
timecatcher Posted September 14, 2009 Author Share Posted September 14, 2009 Anyone please? Im still pretty stuck here. I've tried multiple times to fix but nothing seems to work. Thanks. Tc. Link to comment https://forums.phpfreaks.com/topic/174242-solved-phpcss-issue/#findComment-918554 Share on other sites More sharing options...
MatthewJ Posted September 14, 2009 Share Posted September 14, 2009 ../ means up one level In the first few lines of your css file, you have #banner{ left: 0px; top: 0px; width: 1180px; height: 123px; color: #000000; postion: absolute; background-image: url(images/template/banner.png); } #nav{ left: 0px; top: 123px; width: 150px; height: 300px; color: #000000; postion: absolute; background-image: url(../images/template/navbar.png); Do either the header OR the navbar graphics work? if so, you need to use the same link in both places. Your first link (the one for the banner) is looking for a folder called images in the same directory as the css file. The second link is moving up one level and looking for a folder called images etc.. Link to comment https://forums.phpfreaks.com/topic/174242-solved-phpcss-issue/#findComment-918558 Share on other sites More sharing options...
timecatcher Posted September 15, 2009 Author Share Posted September 15, 2009 Brilliant thanks for the reply! I have it working now . Timecatcher. Link to comment https://forums.phpfreaks.com/topic/174242-solved-phpcss-issue/#findComment-918751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.