getting $_SESSION variables into the...

User 2716615 Photo


Registered User
23 posts

How do I get a session variable to pre-fill part of the form?

I have a login form which checks the user against our ldap and pulls info from the ldap database (email, first and last name etc) I can write that data as session variables and display them on the page but can't seem to get them in the form...

I tried adding 'value=<?php ifisset...etc' to myformname.html

If there is a php element like this in the 'myformname.html' then should it be 'myformname.php?'

does not seem to work? Any help would be much appreciated. Thanks,

Rob.
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Is your server setup to parse php inside a html page?
I use this type of a setup
<?php
session_start();
?>
value="<?php if(isset($_SESSION["myvalue"])) { echo $_SESSION["myvalue"]; }else {echo "0";} ?>"
<?php
unset($_SESSION['myvalue']);
?>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2716615 Photo


Registered User
23 posts

Thanks Eric, it wasn't! I've used a .htacess file now to allow PHP inside html pages under the form directory and it works, as long as I go directly to the MyFormName.html

If I go via the MyFormName.php which WFB generates then - when it redirects to MyFormName.html - it does not parse the PHP.

So I am now confused about the role of the WFB generated 'MyFormName.php since I am bypassing it but it works. What is the relationship between MyFormName.php and MyFormName.html?

For further info my two form set-up is now working as below...
I have a WFB log-in form called 'MyLoginForm' which submits to a custom url page 'MyLoginThanks' where the entries (e.g username) are written to session variables, then it redirects to 'MyFormName.html' which reads the variables into the form. The test works but in production I need to replace 'MyLoginThanks' with the real php page that checks the login against my LDAP user directory. That should work as it outputs the same things e.g. session variables pulled from the directory and a redirect to the main form.

Thanks again for all your help!

Rob.
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Remove the script wrapping the form embed iframe code.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.