PHP file to get username


I have created a php file to grab the username when someone logs onto my site - LogIn.php.

$u = new User();  
$username = $u->getUserName();

I have set this up so that I can grab the username for any third party forms that are submitted on the site. If my understanding is correct I can input code into the external form to grab the username like so: (on lines 3 & 4 of code) [=<?php echo $username; ?>]

<iframe id="JotFormIFrame" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="<?php echo $username; ?> frameborder="0" style="width:100%; height:1013px; border:none;" scrolling="no"></iframe>
<script type="text/javascript">window.handleIFrameMessage = function(e) {var args =":");var iframe = document.getElementById("JotFormIFrame");if (!iframe)return;switch (args[0]) {case "scrollIntoView":iframe.scrollIntoView();break;case "setHeight" = args[1] + "px";break;}};if (window.addEventListener) {window.addEventListener("message", handleIFrameMessage, false);} else if (window.attachEvent) {window.attachEvent("onmessage", handleIFrameMessage);}</script>

Am I missing something very fundamental here in order to get the username on the form as it is still not appearing? Do I need to add a get or post parameter to this in order for it to work? Should this LogIn.php be included in a PHP file already in use?

Help much appreciated.



View Replies:
mhawke replied on at Permalink Reply
2 questions.

1) Where are you currently integrating your LogIn.php page? Is it 'included' somewhere in the login process or are you hoping concrete5 will somehow just know you want this script to run.

2) Are you sure the jotform form is capable of reading the query string and injecting the username parameter into the form?
misebaz replied on at Permalink Reply

1. I was onto Jotform and they advised that I create a php file with this code and then insert code in the form to grab from it anywhere in the website. The LogIn.php file is not integrated with anything.

2. Yes. The code I used above is what they provided me. They were speaking about get and post parameters.

I realise I am missing a step somewhere along the way and I am guessing it is at the log in stage. I could be missing the point altogether too which is probably more likely.