简体   繁体   中英

Self submitting form, then refresh page?

I have a page in PHP with a form that contains multiple checkmarks. These checkmarks can be used to either DELETE the records or create LABELS for whatever is selected.

I got the delete section going just fine as I use the same page ($_SERVER['PHP_SELF']) to run a query, but the labels isn't working because I need to pass the values to another page called PDF_Label_Print.php. I would like to stay away from session variables if possible.

The page works, but sometimes it doesn't refresh automatically. Any ideas? Thanks!

if (isset($_GET['labels']) && (is_array($news_ids) && count($news_ids) > 0))
{
    $label_list  = implode(',', $news_ids);
    echo "<form action='PDF_Label_Print.php' method='post' name='frm' target='_blank'>
    <input type='hidden' name='full_list' value='". htmlentities(serialize($label_list)) ."' />
    <input type='hidden' name='tbl_name' value='" . $_SESSION['officeid'] ."' />
    <input type='hidden' name='report' value='list' />
    <input type='hidden' name='avery' value='5160' />
    </form>";

    echo "<script language='JavaScript'>document.frm.submit();</script>";
    // refresh page.

    echo '<script language="javascript">window.location = "welcome.php"</script>';
}

the problem is that after submitting a form javascript might stop working till the post is done, and the form action is another page.BUT again, when submitting a form (without ajax) the page should refresh automatically.

So what you need is on the PDF_Label_Print.php page to redirect back to the welcome page

header("location:welcome.php"); // or anyother page you want to redirect after posting

Thank you for everyone who took to their time to look at my question.

Turns out I was able to resolve the issue by using POST instead of GET on my form. The header location is now refreshing the page correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM