coldfiretech Posted September 8, 2008 Share Posted September 8, 2008 Okay so im starting to figure this out a little bit.. When i try to define my inputs it keeps giving me an undefined index error on all my variables. Notice: Undefined index: login in C:\wamp\www\matt\registerclass.php on line 15 Too many to post in here so ill kept it short. registerclass.php <?php #class used to process a user registration class register_process{ #variable decleration var $login = ""; var $password = ""; var $email = ""; var $fname = ""; var $mname = ""; var $lname = ""; #sets object's variable from defined POST inputs on the form. function define_inputs(){ $this->login = mysql_real_escape_string($_POST['login']); $this->email = mysql_real_escape_string($_POST['email']); $this->fname = mysql_real_escape_string($_POST['fname']); $this->mname = mysql_real_escape_string($_POST['mname']); $this->lname = mysql_real_escape_string($_POST['lname']); } function check_email(){ #verification user's entered addres is not already in the database as the email address is the user's login username $q = "Select Email from `users` Where Email = '".$this->email."'"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); if(mysql_num_rows($r) >0){ RETURN 0; }else{ RETURN 1;} } } index.php (using this as a test page..) <html> <title>testing class files</title> <?php include("registerclass.php");?> <body> <?php error_reporting(E_ALL); $con = mysql_connect("localhost", "stacks", "island67"); mysql_select_db("cellsavior", $con); $register = new register_process(); //here you're passing $mysqli object to $csx object, so that it could use database connection. $register->define_inputs(); if ($register->check_email() > 0){ //good to go echo "good to go"; }else{ echo "no goood"; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/123212-undefined-index-in-class-file/ Share on other sites More sharing options...
ShaunO Posted September 8, 2008 Share Posted September 8, 2008 It's because you're calling this: $register->define_inputs(); Without having any values in $_POST You need to make a form and post the values Link to comment https://forums.phpfreaks.com/topic/123212-undefined-index-in-class-file/#findComment-636333 Share on other sites More sharing options...
coldfiretech Posted September 8, 2008 Author Share Posted September 8, 2008 okay well ill try that. thanks... im a n00b Link to comment https://forums.phpfreaks.com/topic/123212-undefined-index-in-class-file/#findComment-636335 Share on other sites More sharing options...
coldfiretech Posted September 8, 2008 Author Share Posted September 8, 2008 Okay that worked! Everything except one field!! I have a function called csStates which is like this made the function so i can easily reuse in drop downs without having an extra 50lines of code print " <option value='Alabama'>Alabama</option> <option value='Alaska'>Alaska</option> <option value='Arizona'>Arizona</option> <option value='Arkansas'>Arkansas</option> <option value='California'>California</option>" //ect..... and this is where my actual drop down that calls the csstates function <td class='style20'><strong>State: <span class='green style35'>*</span></strong></td> <td><span id='validselState'> <select name='state' id='state' tabindex='2'> <option selected='selected'></option>"; Im still getting the undefined index on the State field.... here is the line from the class file $this->state = mysql_real_escape_string($_POST['state']); Anyone???? Link to comment https://forums.phpfreaks.com/topic/123212-undefined-index-in-class-file/#findComment-636344 Share on other sites More sharing options...
coldfiretech Posted September 8, 2008 Author Share Posted September 8, 2008 Anyone see what im doing wrong?? ??? Link to comment https://forums.phpfreaks.com/topic/123212-undefined-index-in-class-file/#findComment-636674 Share on other sites More sharing options...
coldfiretech Posted September 8, 2008 Author Share Posted September 8, 2008 stupid thing!!! its working now... for no aparent reason ??? Link to comment https://forums.phpfreaks.com/topic/123212-undefined-index-in-class-file/#findComment-636732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.