MVC

Upon successful submission the admin receives a confirmation email
with the person’s first name only. In the Model file I’m trying to add
both first and last name variables but keep getting errors. I’ve been
through my Fat Book of PHP but can’t find the correct syntax to use.
Here’s the current setup which works great:

else{
	$to = 'email@hidden';
	$subject = 'MAR Submission';
	$body = $this->first . ' has been added to the database. View the  
details at http://somesite.com.';
	$body = print_r($this,true);
	mail($to,$subject,$body,'From: email@hidden','email@hidden');
	if(!is_null($strSession)) $_SESSION[$strSession] = flash($strMessage);
	return header('Location: ' . $strRedirectTo);
	}

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Where does the admin see the first name only? Is it in the subject
line, or in the print_r array you post into the body of the mail
message? Can you post a dump of your sql structure? You may be using
some restricted word for a fieldname, although that’s a guess from
this remove.

Walter

On Nov 20, 2010, at 2:36 PM, Todd wrote:

Upon successful submission the admin receives a confirmation email
with the person’s first name only. In the Model file I’m trying to
add both first and last name variables but keep getting errors. I’ve
been through my Fat Book of PHP but can’t find the correct syntax to
use. Here’s the current setup which works great:

else{
	$to = 'email@hidden';
	$subject = 'MAR Submission';
	$body = $this->first . ' has been added to the database. View the  
details at http://somesite.com.';
	$body = print_r($this,true);
	mail($to,$subject,$body,'From: email@hidden','email@hidden');
	if(!is_null($strSession)) $_SESSION[$strSession] =  
flash($strMessage);
	return header('Location: ' . $strRedirectTo);
	}

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Where does the admin see the first name only?

In the body. For example: Walter has been added to the database. View
the details at http://somesite.com.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Also, if you want to make a “fake variable” like full_name out of
first and last names, try this:

(inside the model)

function full_name(){
return $this->first_name . ’ ’ . $this->last_name;
}

And then, if you have the __get() function set up to map missing
variables to model methods, you can just put in $object->full_name and
get the result you want. If you don’t have __get() in your model path,
then you simply put in $object->full_name() where you want that full
name string to appear.

The __get() trick is defined in _app.php in the latest (Generate)
branch of MAR, and can be added elsewhere using this syntax:

//inside of MyActiveRecord or one of its subclasses:
function __get($variableName){
	if( method_exists($this,"$variableName")){
		return call_user_func(  array($this, "$variableName" ) );
	}
	die('Could not locate ' . $variableName);
}

Walter

On Nov 20, 2010, at 2:36 PM, Todd wrote:

Upon successful submission the admin receives a confirmation email
with the person’s first name only. In the Model file I’m trying to
add both first and last name variables but keep getting errors. I’ve
been through my Fat Book of PHP but can’t find the correct syntax to
use. Here’s the current setup which works great:

else{
	$to = 'email@hidden';
	$subject = 'MAR Submission';
	$body = $this->first . ' has been added to the database. View the  
details at http://somesite.com.';
	$body = print_r($this,true);
	mail($to,$subject,$body,'From: email@hidden','email@hidden');
	if(!is_null($strSession)) $_SESSION[$strSession] =  
flash($strMessage);
	return header('Location: ' . $strRedirectTo);
	}

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I just tried something that seems to work. I added the following to:
$body = $this->first . ’

' . $this->last . '

In context:

function manage_result($strLocal,$strSession,$strMessage='Changes  
saved',$strRedirectTo){
	$strRedirectTo = (substr($strRedirectTo,0,7) == 'http://') ?  
$strRedirectTo : BASE_URL . $strRedirectTo;
	$errors = $this->get_errors();
	if(is_array($errors) && count($errors) > 0){
		return $this->$strLocal = flash($errors,'error');
		}else{
	$to = 'email@hidden';
	$subject = 'MAR Submission';
	$body = $this->first . ' ' . $this->last . ' has been added to the  
database. View the details at http://xiiro.com/dev/MAR/admin/.';
	$body = print_r($this,true);
	mail($to,$subject,$body,'From: email@hidden','email@hidden');
	if(!is_null($strSession)) $_SESSION[$strSession] = flash($strMessage);
	return header('Location: ' . $strRedirectTo);
	}
	return false;
}

I’ll try your method now. Thanks.

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options