Jump to content

Undefined index in class file..


coldfiretech

Recommended Posts

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

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????

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.