2

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()" />
5
  • 5
    did you session_start() ? Commented Apr 5, 2013 at 8:14
  • Elaborating Shivan's question: You need session_start() at the beginning of every page. Commented Apr 5, 2013 at 8:16
  • Yes I have <?php session_start(); ?> at the top Commented Apr 5, 2013 at 8:17
  • As I said, I have no issues with echo'ing the variable on the same page as the form, I just can't get it to echo in the form field Commented Apr 5, 2013 at 8:18
  • @DLO do you have session_start() at the top of every page using $_SESSION? Commented Apr 5, 2013 at 8:28

2 Answers 2

5

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()" />
Sign up to request clarification or add additional context in comments.

2 Comments

@DLO - Do you use an editor or IDE with syntax highlighting? It makes those things very easy to spot.
Using Dreamweaver atm, but do have eclipse
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(); ?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.