PDA

View Full Version : Add spaces to PHP variables



PCGamre
February 1st, 2006, 05:06 PM
I'm working on a large registration form with say, 30 vars in the PHP file.

I have :

$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];

Later, to output to send to email, I have:

$sender_name=$firstname . $lastname;

Okay, now, I've tried to use:
$firstname = $_POST['firstname']. ' ';

and it worked at first (I even tested it and saw the email), but since I've added more vars (b/c the amt of fields in my html form has increased), it doesn't. It just gets ignored.

What I want is to add a space b/t the 2 so when the email gets sent, the "From" line of the email says, eg.:

From: John Doe

and not

From: JohnDoe

hl
February 1st, 2006, 05:23 PM
in the headers where you specify the From:

put $firstname . " " . $lastname

rather than $firstname . " "


it shouldn't really make a difference, but its worth a shot (and better practice - if you had to specify the firstname alone somewhere, it'd always have that stupid little space next to it)

edit:/

since you specified the variable: $sender_name=$firstname . " " . $lastname;

PCGamre
February 1st, 2006, 06:36 PM
Man, why didn't I think of that!

Simple enough and it works. Thanks a bunch, you have taken a little stress away from my day. :)