mr_badger Posted May 14, 2007 Share Posted May 14, 2007 I have just created a registration script, when I view the page there are no errors but I can see code in the browser window, I think I'am missing some brackets but can't figure out were, could someone point it out to me? //array of invalid characters $junk = array('.' , ',' , '/' , '\' , '`' , ';' , '[' , ']' , '-', '*', '&', '^', '%', '$', '#', '@', '!', '~', '+', '(', ')', '|', '{', '}', '<', '>', '?', ':', '"', '='); //starting length of username $len = strlen($_POST['username']); //replace invalid characters $_POST['username'] = str_replace($junk, '', $_POST['username']); $test = $_POST['username']; //if lenghts are different ($len smaller), invalid characters found, so prompt error. if(strlen($test) != $len) { die('Username Error: Username contained invalid characters. You can only use A-Z, 0-9 and the underscore (_).'); } //Check if username already exists... $q2 = mysql_query("SELECT * FROM `members` WHERE `username` = '".$_POST['username']."'"); $q3 = mysql_fetch_object($q2); if($q3->username == $_POST['username']) { die('<BR><BR>Sorry, but the username "'.$q3->username.'" is taken, please choose another.'); } //PASSWORD if(!$_POST['password']) { die('Error: Password field was blank'); } if(!$_POST['verify_password']) { die('Error: Verify Password field was blank.'); } if($_POST['password'] != $_POST['verify_password']) { die('Error: The passwords do not match.'); } if(strlen($_POST['password']) < 6 ) { die('Error: Your password is too short. Must be 6 or more characters in length.'); } //ADD NEW MEMBER $insert ="INSERT INTO `members` (username, user_password, user_email) VALUES ('".$_POST['username']."', '".md5($_POST['password'])."', '".$_POST['email']."')"; $insert2 = mysql_query($insert); if(!$insert2) die(mysql_error()); echo('Registration Successful, Welcome new member! You can now login to your new account.'); } else { ?> Another simple question, what do I have to do when I try and view a php page and get the message Forbidden You don't have permission to access /directory_name/< on this server. Never had this before? Quote Link to comment https://forums.phpfreaks.com/topic/51329-simple-registration-trouble/ Share on other sites More sharing options...
suttercain Posted May 14, 2007 Share Posted May 14, 2007 Is that the entire code? Also can you post the error you are getting. Quote Link to comment https://forums.phpfreaks.com/topic/51329-simple-registration-trouble/#findComment-252789 Share on other sites More sharing options...
mr_badger Posted May 14, 2007 Author Share Posted May 14, 2007 no thats not the entire code, it's just that the error seems to becoming from the start of that code. Quote Link to comment https://forums.phpfreaks.com/topic/51329-simple-registration-trouble/#findComment-252803 Share on other sites More sharing options...
suttercain Posted May 14, 2007 Share Posted May 14, 2007 Repeat from post #2 "Also can you post the error you are getting." Quote Link to comment https://forums.phpfreaks.com/topic/51329-simple-registration-trouble/#findComment-252841 Share on other sites More sharing options...
mr_badger Posted May 14, 2007 Author Share Posted May 14, 2007 this is the entire code <? require_once($_SERVER['DOCUMENT_ROOT'].'/db_connect.php'); //SEE IF ALREADY LOGGED IN if($_SESSION['logged_in'] == 1) { //REDIRECT TO HOMEPAGE header('Location: http://' . $_SERVER['HTTP_HOST'] . ''); } else { if(isset($HTTP_POST_VARS['submit'])) { //BEGIN CHECKING USERNAME... if(!$_POST['username']) die('Alert: username field was blank.'); //array of invalid characters $junk = array('.' , ',' , '/' , '\' , '`' , ';' , '[' , ']' , '-', '*', '&', '^', '%', '$', '#', '@', '!', '~', '+', '(', ')', '|', '{', '}', '<', '>', '?', ':', '"', '='); //starting lenght of username $len = strlen($_POST['username']); //replace invalid characters $_POST['username'] = str_replace($junk, '', $_POST['username']); $test = $_POST['username']; //if lenghts are different ($len smaller), invalid characters found, so prompt error. if(strlen($test) != $len) { die('Username Error: Username contained invalid characters. You can only use A-Z, 0-9 and the underscore (_).'); } //Check if username already exists... $q2 = mysql_query("SELECT * FROM `members` WHERE `username` = '".$_POST['username']."'"); $q3 = mysql_fetch_object($q2); if($q3->username == $_POST['username']) { die('<BR><BR>Sorry, but the username "'.$q3->username.'" is taken, please choose another.'); } //PASSWORD if(!$_POST['password']) { die('Error: Password field was blank'); } if(!$_POST['verify_password']) { die('Error: Verify Password field was blank.'); } if($_POST['password'] != $_POST['verify_password']) { die('Error: The passwords do not match.'); } if(strlen($_POST['password']) < 6 ) { die('Error: Your password is too short. Must be 6 or more characters in length.'); } //ADD NEW MEMBER $insert ="INSERT INTO `members` (username, user_password, user_email) VALUES ('".$_POST['username']."', '".md5($_POST['password'])."', '".$_POST['email']."')"; $insert2 = mysql_query($insert); if(!$insert2) die(mysql_error()); echo('Registration Successful, Welcome new member! You can now login to your new account.'); } else { ?> The error when I view the page in the broswer is that I can see some of the code and when I click the submit button I get a 403 Forbidden You don't have permission to access /directory_name/< on this server. In the address bar it says this: http://localhost/directory_name/%3C?%20$_SERVER['PHP_SELF'];%20?%3E It's not a php error. Quote Link to comment https://forums.phpfreaks.com/topic/51329-simple-registration-trouble/#findComment-252920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.