garry27 Posted October 15, 2006 Share Posted October 15, 2006 hi, i'm new to php and this forum so i hope that somone can help me.i've been stuck on this problem for all day. i'm trying to create a registration feature for a website which i'm practically copying most of it from a book but the script won't work. i get various errors at run-time.here's my script which is supposed to add a new user (using a function register() available in register_fs.php shown further down the page) to my mysql table which is already created.[code]<?php //register_pa.php /*****open function scripts and open a session *************************/ require_once('common.php'); require_once('register_fs.php'); session_start(); //outputs header info to brower with the following title echo xhtmlheader('Error'); //outputs the main navigation bar to the browser //echo topnav_pa(); $email = $_GET['email']; $pwd = $_GET['pwd']; $forename = $_GET['forename']; $pwd2 = $_GET['pwd2']; $surname = $_GET['surname']; $gender = $_GET['gender']; /* $agree_terms = $_GET['agree_terms']; */ if (!get_magic_quotes_gpc()) { $email = addslashes($email); $pwd = addslashes($pwd); $forename = addslashes($forename); $surname = addslashes($surname); $gender = addslashes($gender); } // turn off run-time error notices $old_level = error_reporting(E_ALL & ~E_NOTICE); try { //checks if all the fields in the form are filled out if (!filled_out($_POST)) { throw new Exception("You have not filled the form out correctly" ."- please go back and try again."); } if ($pwd != $pwd2) { throw new Exception("The passwords you entered do not match" ."- please go back and try again."); } if (strlen($pwd)<6 || strlen($pwd) >16) { throw new Exception("The password must be at least 6 characters long" ."- please go back and try again."); } /****** attempt to register ****************************************************/ register_pa ($email, $pwd, $forename, $surname, $gender); $_SESSION['valid_user'] = $email; echo 'your registration was succesful'; echo "<br/><br/><a href='pau_home.php'>Go to members page</a>"; echo xhtmlheader('Registration Completed'); } catch (Exception $e) { echo $e->getMessage(); exit; } // revert back to default error report values error_reporting(£old_level);?>[/code] here's my register_fs script:[code]<?php //register_ps.phpfunction filled_out($form_vars){ // test that each variable has a value foreach ($form_vars as $key => $value) { if (!isset($key) || ($value == '')) return false; } return true;}function register_pa ($email, $pwd, $forename, $surname, $gender){ //connect to database $conn = db_connect(); //check username is unique $result = $conn->query("select * from Authourised_User where userEmail='$email'"); if(!$result) throw new Exception('could not execute query'); if($result->num_rows>0) throw new Exception ('That e-mail address is already registered with us' .'- please go back and choose a different one.'); //if ok, put in db $result = $conn->query("INSERT into Authourised_User values ('$email', ('$pwd') set userPassword='$pwd'"); if (!$result) throw new Exception ('Could not register you in database ' .'- please try again later.'); return true;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23970-need-help-with-script/ Share on other sites More sharing options...
darkcarnival Posted October 15, 2006 Share Posted October 15, 2006 for the form values i'd use $_POST instead of $_GET.also session_start should always be first.it would also help us if you posted what errors you get and maybe even a demo so we can see it for ourselves. Quote Link to comment https://forums.phpfreaks.com/topic/23970-need-help-with-script/#findComment-108919 Share on other sites More sharing options...
garry27 Posted October 15, 2006 Author Share Posted October 15, 2006 hiya, thanks for replying!i've commented out the exception error statements on the functions page and now I get undefined index errors when i submit the register form:http://www.nl-webspace.co.uk/~unn_p921847/[email protected]&pwd=asdfgh&forename=garry&pwd2=asdfgh&surname=mccabe&gender=m&ta_terms=%09++++&pa_regfrmbtn=Register???????? Quote Link to comment https://forums.phpfreaks.com/topic/23970-need-help-with-script/#findComment-108922 Share on other sites More sharing options...
garry27 Posted October 15, 2006 Author Share Posted October 15, 2006 help! Quote Link to comment https://forums.phpfreaks.com/topic/23970-need-help-with-script/#findComment-109033 Share on other sites More sharing options...
darkcarnival Posted October 18, 2006 Share Posted October 18, 2006 thats a notice error.it's just an non-error error, meaning it wont kill off your program but it will annoy you to death.I believe there is a way to disable it in your script but i'll have to do some more on that before i do anything more. Quote Link to comment https://forums.phpfreaks.com/topic/23970-need-help-with-script/#findComment-110394 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.