Pass PHP session variable into HTML form

20,187

Solution 1

This should work...the quote before value was probably screwing it up

<input type="text" name="email" id="email" size="36" value="<?php echo $_SESSION['newsletterSignup'];?>" class="text-input" onBlur="emailval()" />

Solution 2

you use

<input type="text" name="email" id="email" size="36" "value="<?php echo $_SESSION['newsletterSignup'];?>" class="text-input" onBlur="emailval()" />

A " to many. Here is the fix

<input type="text" name="email" id="email" size="36" value="<?php echo $_SESSION['newsletterSignup'];?>" class="text-input" onBlur="emailval()" />

Also, did you use session_start(); ?

Share:
20,187
DLO
Author by

DLO

Updated on April 05, 2020

Comments

  • DLO
    DLO about 4 years

    I have session variables that are posted from a form on another php page, and I can echo them by using:

    <?php $_SESSION['newsletterSignup'] = $_POST['newsletterSignup'];
    echo "Email = ". $_SESSION['newsletterSignup'];
    ?> 
    

    But I can't seem to insert these into a HTML form field:

    <input type="text" name="email" id="email" size="36" "value="<?php echo $_SESSION['newsletterSignup'];?>" class="text-input" onBlur="emailval()" />
    
  • jwueller
    jwueller about 11 years
    @DLO - Do you use an editor or IDE with syntax highlighting? It makes those things very easy to spot.
  • DLO
    DLO about 11 years
    Using Dreamweaver atm, but do have eclipse