简体   繁体   中英

How do you redirect to a popup using php and not javascript?

I find tons of ways to do it in javascript, but I need to call smack in the middle of a php script.

<form action="" method="POST" target='popup' onsubmit="window.open('','popup','width=700,height=400,left=200,top=200,scrollbars=1')">
        Send a message  : <input type="text" name="twitmessage"><br>
        <input type="checkbox" name="twitter" value="My Posting Text">Would you like to send to Twitter?<br>
        <input type="checkbox" name="facebook" value="Stuff to Post to facebook">Would you like to post to Facebook?<br>
        <input type="submit" name="submit_cycle" value="Submit">
</form>
<?php
session_start();
// store session data
$_SESSION['twitmessage'] = $_POST['twitmessage'];

if(isset($_POST['submit_cycle'])) {
        if($_POST['twitter']){
                header("location: ../index.php?p=members");
        }
        if($_POST['facebook']){
                header("location: ../index.php?p=paybill");
        }else{
                echo "Something bad happened";
        }
}
?>

You can't.

Opening a window is a client-side operation which cannot be performed using PHP. That's by principle.

You can generate the JS, which will open a new window on the client-side.

<script>
    window.open('<?php echo htmlentities($url); ?>')
</script>

Another approach. Maybe I didn't get your intention right.

To open the twitter dialog in a different window you could simply add target=_blank to your form.

The rest should be the same as above.

To create a sized window, create a new, named window. Then scale it and set the target of the form to the window's name.

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