Jump to content

Recommended Posts

Hi guys,

I'm trying to use the user input submitted and given to registerStageOne(). It's given by parameters in the function, then it returns the array. Here's the code:

 

userCore.php

class userCore {
		
		public $registerStageOne = array();
		public $registerStageTwo = array();
		
		
		public function registerStageTwo($d, $m, $y, $g) {
		require_once("cmsCore.php");
			$registerStageOne = array($d, $m, $y, $g);
			return $registerStageOne;
		}
		
		public function registerStageThree($u, $e, $p, $rp) {
			if($p==$rp) {
				echo 'they match!';
				$registerStageTwo = array($u, $e, $p, $rp);
				echo $registerStageTwo[1];
				
			}
			else {
				echo 'Your Passwords do not match!';
			}
		}
		
	}
	
$userCore = new userCore();

register.php:

<?php
	if(!isset($_GET['stage'])) {
		require_once($obj->getTPLDir() . "register-one.tpl");
	} else {
		switch($_GET['stage']) {
			case "2":
			if(empty($_POST['bean_day']) || empty($_POST['bean_month']) || empty($_POST['bean_year'])) {
				echo 'you have not filled out the form.';
			}
			$usersCore->registerStageTwo($_POST['bean_day'],$_POST['bean_month'],$_POST['bean_year'],$_POST['bean_gender']);
			require_once($obj->getTPLDir() . "register-two.tpl");
			break;
			
			case "3":
			$usersCore->registerStageThree($_POST['bean.name'], $_POST['bean.email'], $_POST['bean.password'], $_POST['bean.retypedPassword']);
			// require_once($obj->getTPLDir() . "register-three.tpl");
			break;
		}
	}
?>

I want to take the data from $usersCore->registerStageTwo() and hold it (or pass it down to $usersCore->registerStageThree()) the reason I want it here is so that I can import it into the database at the end of stage three.

 

Many thanks for your help.

 

Link to comment
https://forums.phpfreaks.com/topic/278594-variable-from-one-function-to-another/
Share on other sites

that's not really an object.  You have basicly written procedural code and wrapped an object container around it, you could actualy take away the class{} from the outside of that code, drop the scope deffinitions and that would work just as it is in the raw page.

 

Some key points to address -

you have echo's within the methods within your object

you never actually assign anything to your objects parameters

you have a require within your object

you have everything as public

and - not specific to oop, but - you have a method named the same as a parameter

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.