• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5097
  • Last Modified:

Javascript popup, return to parent, close popup, run php program, passing a variable...

Not sure if this has been answered but I couldn't find it, although some questions were along the same lines in some way.  In a nutshell:

User chooses menu option
Open a popup number keypad
Get a login id and pass that to a php program
Check a mysql database for security level
If cleared, close the popup
Return to parent
Run the called php program, passing along user id.

It all worked great until I decided to make the number keypad a popup.  Having problems getting back to parent and finishing the task list.

Parent window is a menu.  Contains popup function:

   <SCRIPT LANGUAGE="JavaScript">
   function popUp(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=245,height=355,left = 277,top = 122');");
   }
   </script>
   
When the user clicks menu item, I want to get a login id to check security access level for clearance.  The onclick pops up a number keypad whihc has been passed the name of the program to run if clearance is granted via mysql database as well as the calling program:

<div onclick="javascript:popUp('login.php?runprog=bomain.php&fromprog=index.php')">Back Office</div>


The login.php is a simple number keypad popup to allow user to enter a number.  When enter is pressed:

Calling:     <div Onclick="ChkAccess()">Enter</div>

function:
function ChkAccess()
{
   if (document.Login.Get_Logid.value != '0')
      window.location=''+ 'chkaccess.php?logid=' + document.Login.Get_Logid.value + '&runprog=<?php ECHO($liprogrun);?>'+ '&fromprog=<?php ECHO($lifromprog);?>' ;
}

ChkAccess.php snip that grants access:

        if ( $chksecreq <= $eseclvl ) {
           header("Location: $chkprogrun?logempid=$eempid");
           exit;
        } else {

This obviously opens the called program, passing along the user login code...

The problem is that I want the child-popup to return to the parent before opening the
called program.

I found the following JS on here and it sounded like it might do the trick, but alas, I was'nt sure where to put it and I wasn't at all sure of how to tell it to open the called program, passing along the user login code.  I presume my implementation is incorrect and/or the placement is incorrect, or I am simply way off base because I am a moron :) In over my head here. Can anyone show me the way?

Tried the following thinking it would return to parent and close the popup:

        if ( $chksecreq <= $eseclvl ) {
-->      <script>window.opener.location.reload(true);self.close();</script>
           header("Location: $chkprogrun?logempid=$eempid");
           exit;
        } else {...

Thanx a mil' for any help provided...
Owen
0
owenparker
Asked:
owenparker
  • 4
  • 3
1 Solution
 
Kiran Paul VJComputer EngineerCommented:
try this

 if ( $chksecreq <= $eseclvl ) {
          echo("<html><head></head><body>");
          echo("<script>window.opener.location.reload(true);self.close();</script>");
          echo("</body></html>");          
          //header("Location: $chkprogrun?logempid=$eempid");
          exit;
        } else {...
0
 
Kiran Paul VJComputer EngineerCommented:
and if you want to load  $chkprogrun?logempid=$eempid" in the parent try this

 if ( $chksecreq <= $eseclvl ) {
          echo("<html><head></head><body>");
          echo("<script>window.opener.location.href='".$chkprogrun?logempid=$eempid."'';self.close();</script>");
          echo("</body></html>");          

          exit;
        } else {...
0
 
owenparkerAuthor Commented:
Sorry kiranvj, same result.  Click button, runs login.php in a popup, get login id, runs chkaccess.php, then opens called program (in this case bomain.php in popup window.  Problem seems to lie in the fact that i really need to go back 2 programs

index.php --> logn.php --> chkaccess.php --> back to index.php, close popup, run new program

any way to hop back twice or will it be necessary to do it via some sort of variable passing scema?
Thanx so much for the effort.  It looked like it had teeth :)
Owen
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
owenparkerAuthor Commented:
Yes that's definitely the problem.  Chkaccess is dropping back to the popup whihc called it.  Is there a way to drop back to the original parent, or two children, so to speak?
0
 
Kiran Paul VJComputer EngineerCommented:
If i get it correctly, this is what you want

index.php --> logn.php(Popup) --> Now user enters username and password and click login button-> Now close the popup and do login validation in chkaccess.php and reloads the index.php. Right??

if thats the case try some think like

function ChkAccess()
{
   if (document.Login.Get_Logid.value != '0')
     {
     
      window.opener.location=''+ 'chkaccess.php?logid=' + document.Login.Get_Logid.value + '&runprog=<?php ECHO($liprogrun);?>'+ '&fromprog=<?php ECHO($lifromprog);?>' ;
     self.close();
     }
}
0
 
owenparkerAuthor Commented:
kiranvj, that was peerfect.  It sure does help to have to think things thru to explain to another.  Thanx for that and the perfect syntax and positioning for the code :)
Owen
0
 
Kiran Paul VJComputer EngineerCommented:
thanks Owen, your comment was a great motivation.
thanks once again for the points and grade and glad i could help you.

cheers,
kiranvj
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now