Inserting PHP Code Variable In Form

I’ve done this before, and this page work fine. However now I’m getting some parse errors. I just can’t see where the errors might be in the PHP code.

What I want to do is place the domain & page address in a user login log table via login form. I have a step that inserts this info plus a timestamp and username after the login validation takes place. See the

<?php $domain = $_SERVER["SERVER_NAME"]; $page = basename($_SERVER["PHP_SELF"]); $domain_page = $domain . "/" . $page; ?>

Inside the form I have the following input field…

Should I set up var using Wappler and forgo the actual <?php ; ?>?

I did it in one of these tips

Thanks!

What threw me is that these pages were working fine for over three months or more. This parse error pop up after I made some adjustments to the pages.

Thanks for the ‘tips’ sheet!

No problem, and please feel free to add more tips when you find little nuggets, i always forget to add.

1 Like

I looked at your php code and the solution is sound, however as far as I know there are parameters in the browser component that can do this in a far simpler way.

  1. add your browser component
  2. Look at browser data bindings > location > href
    This should produce {{browser1.location.href}} the only issue I know with it is that if you use routes it is still going to show the original path and not the more clean route path you chose.

Man, I am not acquainted with that facet of the browser component. Thanks for another option. I am an amateur compared to you guys. I know virtually nothing compared to you all. I appreciate all the help you provide.

1 Like

Dont worry, i did the same thing as you, until Teodor pointed it out to me a few months back. hahaha, once you know its under location it makes sense, but when you first see the browser component parameters you almost expect location to be for map stuff, lol

I put a few lines of code demonstrating most of the browser component features. You can paste the code into any page to see the results. Here’s the thread.

2 Likes

Brilliant Tom, that is going to be pretty helpful, thank you.