richie_ropey Posted January 6, 2007 Share Posted January 6, 2007 I'm having a problem with a couple of classes which dont seem to want to interact with each other, the way it works is:[b]users.php/user_control.php[/b] (contains various functions) ---- pass information to....[b]page_control.php[/b] (controls which actions should be used where and decides weather to show them or not based on users status) ------ which in turn passes to.....index.php (which contains all display information and navigation, pics , etc...)im getting an error saying: [b]Fatal error: Call to a member function registrationForm() on a non-object in C:\Program Files\xampp\htdocs\wf\user_class\page_control.php on line 21.[/b] which implys that i have not declared the function in users.php (which is included in get_content.php).[b]page_control.php[/b][code]<?phpinclude('user_control.php');include('users.php');$registration = new registration;$user_control = new userControl;class pageControl{ var $level; function getContent() { if (!isset($_GET['action'])) { if ($this->restrictedPage(4, true)==false) { ?><link rel="stylesheet" href="CSS/large_forms.css" /><?php $registration -> registrationForm(); } else { $this->restrictedPage(4, true); } }[/code]not pasting it all :P[b]users.php[/b][code]<?php session_start();class registration { var $error; var $error_msg_username; var $error_msg_password; var $error_msg_validate; var $error_msg_email; var $user_ID; var $username; var $password; var $password_check; var $email; var $date_registerd; var $occupation; var $location; var $active; var $stats_ID; var $axx_level; var $u_title; var $last_active_time; var $last_active_day; var $last_active_date; var $cookie_hash; var $last_known_IP; function process() { $this->validateForm(); if ($this->error == true) { $this->errorReport(); } else { $this->processForm($this->username, $this->password, $this->email, $this->date_registerd, $this->occupation, $this->location, $this->active); $this->processStats($this->user_ID, $this->axx_level, $this->u_title, $this->last_active_time, $this->last_active_day, $this->last_active_date, $this->cookie_hash, $this->last_known_IP); $this->conformationEmail($this->username, $this->active); } } function registrationForm() { ?> <div class="note">* denotes a required field</div> <form action="index.php?action=process" method="post"> <div class="formSection"> <div> <div class="formLabel">Username*:</div> <div class="formInput"> <?php if (!($_POST['username'])) { ?> <input type="text" name="username" /> <?php } else { ?> <input type="text" name="username" value="<?php echo $_POST['username'] ?>" /> <?php } ?> </div> </div> <div> <div class="formLabel">Password*:</div> <div class="formInput"><input type="password" name="password" /></div> </div> <div> <div class="formLabel">Password conformation*:</div> <div class="formInput"><input type="password" name="password_check" /></div> </div> <div> <div class="formLabel">Email*:</div> <div class="formInput"> <?php if (!($_POST['email'])) { ?> <input type="text" name="email" /> <?php } else { ?> <input type="text" name="email" value="<?php echo $_POST['email'] ?>" /> <?php } ?> </div> </div> <div> <div class="formLabel">Occupation:</div> <div class="formInput"> <?php if (!($_POST['occupation'])) { ?> <input type="text" name="occupation" /> <?php } else { ?> <input type="text" name="occupation" value="<?php echo $_POST['occupation'] ?>" /> <?php } ?> </div> </div> <div> <div class="formLabel">Location:</div> <div class="formInput"> <?php if (!($_POST['location'])) { ?> <input type="text" name="location" /> <?php } else { ?> <input type="text" name="location" value="<?php echo $_POST['location'] ?>" /> <?php } ?> </div> </div> </div> <div class="formSection"> <h5 style="font-weight:normal">Please enter the string shown in the image in the form.<br> The possible characters are letters from A to Z in lower case form and the numbers from 0 to 9. This is required to confirm your registration.</h5> <div class="formInput"><input name="number" type="text"><br /><img src="includes/random_image.php"></div> </div> <div class="formSection"> <input type="submit" name="button" value="Submit"> </div> </form> <?php }[/code][u][i][b]registrationForm()[/b][/i][/u] <-------------------------------------- see look right there, its declared. please help before i start loosing my hair though stress, im only 19 and i like my hair ;) Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted January 6, 2007 Share Posted January 6, 2007 do you forget your function (method) variable scope young padawan? :Pyou aren't allowed to use variables declared outside the function (method) inside that method. In this case $registration Quote Link to comment Share on other sites More sharing options...
richie_ropey Posted January 6, 2007 Author Share Posted January 6, 2007 genericnumber1, thank you very much but I already got owned on IRC for being a noob on that subject :D. My first proper atempt at a user class. Hope this helps anyone in the future :) Quote Link to comment 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.