Submitting for from iframe

Posted on 2006-05-29
Last Modified: 2008-03-06
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,

Question by:andy7789
    LVL 49

    Accepted Solution

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

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


    Author Comment

    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!!

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to count occurrences of each item in an array.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now