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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.