1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to add name to every page of application (PHP)

Discussion in 'PHP & Perl' started by ibmethatswhoib, Apr 4, 2013.

  1. ibmethatswhoib

    ibmethatswhoib Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 17, 2011
    Messages:
    1,560
    Likes Received:
    1,156
    Occupation:
    Staying Informed
    Location:
    Bay Area, Ca
    Home Page:
    So my company has an online application built in PHP and people fill it in and it sends it to a database. Well the company asked me to add the applicants name to every page somewhere, I'm guessing so when they print them out it will have the name on every page of the application. I'm not too good with PHP is there a way to do that?

     
  2. innozemec

    innozemec Jr. VIP Jr. VIP

    Joined:
    Aug 19, 2011
    Messages:
    5,290
    Likes Received:
    1,799
    Location:
    www.Indexification.com
    Home Page:
    <?php echo $name;?>

    that prints a variable to the screen. Simply replace $name with the proper variable holding the name..
     
    • Thanks Thanks x 1
  3. geomuss

    geomuss Regular Member

    Joined:
    May 19, 2011
    Messages:
    243
    Likes Received:
    110
    Are you calling it from the database ?
     
  4. Vjo7a

    Vjo7a Registered Member

    Joined:
    Dec 30, 2010
    Messages:
    68
    Likes Received:
    13
    If it's about a form, you can have access to the name variable from the form by using the $_POST or $_GET (depending on what method you are using to send the info) or $REQUEST['name'].
    Then you just need to echo those values :
    PHP:
    <?php echo $_POST['name']; ?> 
    <?php echo $_GET['name']; ?>
    Now, to display variables that are sent by a user in a form you can make those values sticky like this:

    PHP:
    <?php if (isset($_POST['name']) && (!empty($_POST['name'])) echo $POST['name']; ?>
    That line can be reduced by making a custom function and detect wether a variable was submitted or not and just outputing the value....but everything depends on your logic and how you are sending the data :)