1

I have a form that is pulling data from my db and displaying it on the form based on which user is logged in. The first form field is the user's name. I have their first and last name displaying in the form, but I need to add a space in between the first and last name.

Here is the code:

<input type="text" name="form-partner-name" placeholder="Partner name" class="form-partner-name form-control" id="form-partner-name" 
                                                value="<?php echo $_SESSION['user']['firstName'], $_SESSION['user']['lastName']?>">

How do I add a space between the first and last name?

K. Carskadon
  • 49
  • 12
  • Maybe make a full name index as well at assignment? `$_SESSION['user']['fullname'] = $row['firstname'] . ' ' . $row['lastname'];` or you could `concat` in the SQL and return it as `fullname`. – chris85 Jun 19 '17 at 18:06

3 Answers3

3

Just add a space in your echo statement as an argument.

<input type="text" name="form-partner-name" placeholder="Partner name" 
class="form-partner-name form-control" id="form-partner-name" 
                                            value="<?php echo 
$_SESSION['user']['firstName'], " ", $_SESSION['user']['lastName']?>">
Cameron Roe
  • 290
  • 1
  • 9
0
<?php echo $_SESSION['user']['firstName'] . ' ' . $_SESSION['user']['lastName']?>

Add quoted space ' ' and concat it with firstName and lastName.

Ivan Bolnikh
  • 742
  • 9
  • 19
0

Simpler

<input type="text" name="form-partner-name" placeholder="Partner name" class="form-partner-name form-control" id="form-partner-name" 
value="<?=$_SESSION['user']['firstName'] . ' ' . $_SESSION['user']['lastName']?>">
JLGarcia
  • 336
  • 2
  • 5