twistedvengeance Posted June 12, 2012 Share Posted June 12, 2012 So me and my team of developers are creating a web based flash game, and I've been working on the register page. Thing is, I can't get it to submit the given information to the database. I think it may be something to do with my functions, since this is the first I've worked heavily with them. *EDIT* I added in the whole page incase there was some confusion <?php $name = $_POST['name']; //Get Name $password = $_POST['password']; //Get Password $ppassword = $_POST['ppassword']; //Get Repeated Password $username = $_POST['username']; //Get Username $email = $_POST['email']; //Get Email $age = $_POST['age']; //Get Age $hashname = (md5($hash . $name)); //Hash Name $hashpw = (md5($hash . $password)); //Hash Password $checkcont = file('blocked.txt'); //Blocked User Input Content function Register(){ // Insert Function /* Create User Login Account*/ mysql_query("INSERT INTO accounts ( name , password , username , email , age ) VALUES ( $name , $password , $username , $email, $age )"); /* Create User Character Field 1 */ mysql_query("INSERT INTO users ( chr , password , username , slot , auth , exp , money , name ) VALUES ( 'null' , $hashpw , $username , 1 , 1 , 'null' , 'null' , $hashname)"); /* Create User Character Field 2 */ mysql_query("INSERT INTO users ( chr , password , username , slot , auth , exp , money , name ) VALUES ( 'null' , $hashpw , $username , 2 , 1 , 'null' , 'null' , $hashname)"); /* Create User Character Field 3 */ mysql_query("INSERT INTO users ( chr , password , username , slot , auth , exp , money , name ) VALUES ( 'null' , $hashpw , $username , 3 , 1 , 'null' , 'null' , $hashname)"); } function Email(){ //Create & Send Email Link } function CheckInput(){ //Check User Input $errors = 0; //Set Errors Null $swears = 0; //Set Swears Null $notos = 0; //Set TOS Null if($name !== null){ if($name !== $checkcont){ if($password !== null){ if($password !== $checkcont){ if($ppassword !== null){ if($username !== null){ if($username !== $checkcont){ if($email !== null){ if(isset($_POST['tos'])){ if($age !== null){ Register(); }else{ $errors++; } }else{ $notos = 1; } }else{ $errors++; } }else{ $swears++; } }else{ $errors++; } }else{ $errors++; } }else{ $swears++; } }else{ $errors++; } }else{ $swears++; } }else{ $errors++; } } if(isset($_POST['submit'])){ CheckInput(); } ?> <?php $browser = array( 'version' => '0.0.0', 'majorver' => 0, 'minorver' => 0, 'build' => 0, 'name' => 'unknown', 'useragent' => '' ); $browsers = array( 'firefox', 'msie', 'opera', 'chrome', 'safari', 'mozilla', 'seamonkey', 'konqueror', 'netscape', 'gecko', 'navigator', 'mosaic', 'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol' ); if (isset($_SERVER['HTTP_USER_AGENT'])) { $browser['useragent'] = $_SERVER['HTTP_USER_AGENT']; $user_agent = strtolower($browser['useragent']); foreach($browsers as $_browser) { if (preg_match("/($_browser)[\/ ]?([0-9.]*)/", $user_agent, $match)) { $browser['name'] = $match[1]; $browser['version'] = $match[2]; @list($browser['majorver'], $browser['minorver'], $browser['build']) = explode('.', $browser['version']); break; } } } ?> <html> <!-- This Is Our Header --> <head> <script> function getbrowser(){ open = window.open("getbrowser.php", "open", "location=1,status=1,scrollbars=1, width=300,height=300"); open.moveTo(0, 0); } </script> <title> The Dragon Seige™ Register </title> <?php if($browser['name'] == "chrome"){ $using = 1; echo "<link href=\"styles/chromereg.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />"; }elseif($browser['name'] == "firefox"){ $using = 2; echo "<link href=\"styles/firefoxreg.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />"; } if(($using !== 1) && ($using !== 2)){ echo ""; } ?> </head> <!-- This Ends Our Header --> <!-- This Is Our Body --> <body> <?php if(($using == 1) || ($using == 2)){?> <div id="registerwrap"> <?php include('inc/header.php'); ?> <div class="content"> <center> <div id="registercont"> <h2> Registration </h2> <hr width="99.9%" color="red" size="5px" /> <?php if($errors > 0){ //If Errors, Make Aware echo "There are errors on your registration.<br/>";} if($swears > 0){ //If Swears, Make Aware echo "Please do not use inappropriate content.<br/>";} if($notos > 0){ //If NoTos, Make Aware echo "Please accept the Terms Of Service.<br/>";} ?> <form action="" method="post"> <fieldset> <legend>Personal / Login Information</legend> <table width="98%"> <tr> <td width="49%">Name:[Full Name]</td> <td width="49%"><input type="text" style="width: 98%;" name="name" id="name"></td> </tr> <tr> <td>Password:<br/>[6-30 Characters]</td> <td><input type="password" style="width: 98%;" name="password" id="password"></td> </tr> <tr> <td>Re-Enter Password:</td> <td><input type="password" style="width: 98%;" name="ppassword" id="ppassword"></td> </tr> <tr> <td>Username:<br/>[Login Name]</td> <td><input type="text" style="width: 98%;" name="username" id="username"></td> </tr> <tr> <td>e-Mail:[Activation]</td> <td><input type="email" style="width: 98%;" name="email" id="email"></td> </tr> <tr> <td>Age:[For Content]</td> <td><select name="age" id="age" style="width:98%;"> <option value="noage" id="noage" name="noage">Select Age</option> <?php $age = 13; while($age < 41){ //Make Age Field echo "<option value=\"$age\">" . $age . "</option>"; $age++; } ?> <option value="other" id="other" name="other">Older</option> </td> </tr> </table> </fieldset> <p align="left">By agreeing to these terms of service, you hereby agree that you are either of legal age, or have consent of a parent and/or guardian, to view and play this game. You agree to abide by the rules of the game, along with being respectful to all players. You understand that the proper consequences will be taken against you if you break any rule of the game, or break the terms of service.</p> <div id="tos"> <table width="100%"> <tr> <td width="85%">I Understand And Agree To The Terms Of Service.</td> <td width="5%"><input type="checkbox" style="margin-top:2px;" name="tos" id="tos" /></td> </tr> </table> </div> <br/> <input type="submit" style="background-color: white;" value="Register" name="Register" id="Register" /> </form> </div> </center> <?php include('inc/footer.php'); ?> </div> </div> <?php }else{ ?> <body onload="getbrowser()"> <?php } ?> </body> <!-- This Ends Our Body --> </html> Now, I'm no expert at PHP, but I honestly don't understand why this isn't working. Can anyone give me some tips? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/264050-calling-custom-functions-problem/ Share on other sites More sharing options...
KevinM1 Posted June 12, 2012 Share Posted June 12, 2012 1. Are you getting any errors/warnings? 2. Are you actually connecting to the db? 3. Have you manually tested your queries? Quote Link to comment https://forums.phpfreaks.com/topic/264050-calling-custom-functions-problem/#findComment-1353168 Share on other sites More sharing options...
twistedvengeance Posted June 12, 2012 Author Share Posted June 12, 2012 1. Are you getting any errors/warnings? 2. Are you actually connecting to the db? 3. Have you manually tested your queries? I am getting no errors, nothing is happening. It's like the submit button isn't being checked. I am connecting to the database. I have used the queries on another script to test them. Quote Link to comment https://forums.phpfreaks.com/topic/264050-calling-custom-functions-problem/#findComment-1353169 Share on other sites More sharing options...
KevinM1 Posted June 12, 2012 Share Posted June 12, 2012 Your submit button is named 'Register', but you check for $_POST['submit'] in your code. Quote Link to comment https://forums.phpfreaks.com/topic/264050-calling-custom-functions-problem/#findComment-1353170 Share on other sites More sharing options...
twistedvengeance Posted June 12, 2012 Author Share Posted June 12, 2012 Your submit button is named 'Register', but you check for $_POST['submit'] in your code. I feel like an idiot for not seeing that, but that didn't change anything unfortunately. Quote Link to comment https://forums.phpfreaks.com/topic/264050-calling-custom-functions-problem/#findComment-1353172 Share on other sites More sharing options...
PFMaBiSmAd Posted June 12, 2012 Share Posted June 12, 2012 You need to set php's error_reporting to E_ALL and display_errors to ON in your master php.ini to get php to help you. Stop and start your web server to get any changes made to your master php.ini to take effect and use a phpinfo statement to confirm that the settings got changed in case the php.ini that php is using is not the one that you changed. Just about all the variables that are inside of your various functions don't exist in the scope where you are using them. Quote Link to comment https://forums.phpfreaks.com/topic/264050-calling-custom-functions-problem/#findComment-1353173 Share on other sites More sharing options...
twistedvengeance Posted June 12, 2012 Author Share Posted June 12, 2012 You need to set php's error_reporting to E_ALL and display_errors to ON in your master php.ini to get php to help you. Stop and start your web server to get any changes made to your master php.ini to take effect and use a phpinfo statement to confirm that the settings got changed in case the php.ini that php is using is not the one that you changed. Just about all the variables that are inside of your various functions don't exist in the scope where you are using them. So I did that, and got a "unknown variable" blah blah, and fixed that by placing all of my POST checks into a function and calling it inside of my CheckInput function, but I'm still getting the error. Quote Link to comment https://forums.phpfreaks.com/topic/264050-calling-custom-functions-problem/#findComment-1353174 Share on other sites More sharing options...
twistedvengeance Posted June 12, 2012 Author Share Posted June 12, 2012 Thanks for trying to help guys, I figured it out. My function wasn't being called in the right place. Quote Link to comment https://forums.phpfreaks.com/topic/264050-calling-custom-functions-problem/#findComment-1353176 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.