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

Submitting for from iframe

Hi X-perts,

I have a main page main.php containg 2 iframes country.php and city.php. The last iframe city.php is sending a form to itself using $_SERVER['PHP_SELF']. Next, after city.php updates the database fields I use the following code to redirect the page:

$updateGoTo = "main.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $updateGoTo));

The problem is that it opens a new page, but I need to stay on my original main.php with those 2 frames. How can I do it?
This works fine for normal pages with no iframes, i.e. it updates the fields and remains on the same page, but iframes make this trouble. If I remove the above code, it opens a new city.php as a new page also.

Thank you,

1 Solution
Do you have target="top" on your <form> tag?

Otherwise the city.php should just stick in its own frame.

andy7789Author Commented:
Sorry, for a silly question! Of course, it was just a "blank" target onthe form ... just have not noticed it when copying from another template form!! Spent a few hours debugging php, and it was just this typo.

thanks a lot!!
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.

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