open new window with php code after form submits results

て烟熏妆下的殇ゞ 提交于 2019-12-09 00:58:35

问题


here is the script that i been working on , it is supposed to integrate user and pass when opened

<?php

$name = $_POST['name']; // contain name of person
$pass = $_POST['pass']; // Email address of sender 
$link = window.open(https://secure.brosix.com/webclient/?nid=4444&user=$name&pass=$pass&hideparams=1 'width=710,height=555,left=160,top=170');

echo $link;

?>

am i doing this right, i want to open a pop up windows after the user submits the form to the php code but i always get an error.


回答1:


Change your code to this

<?php

$name = $_POST['name']; // contain name of person
$pass = $_POST['pass']; // Email address of sender 
$link = "<script>window.open('https://secure.brosix.com/webclient/?    nid=4510&user=$name&pass=$pass&hideparams=1', 'width=710,height=555,left=160,top=170')</script>";

echo $link;

?>

Additional Note

You should consider using fancybox which can load webpages as a whole in a popup window using iframes. There are other options as well feel free to explore!




回答2:


You forgot to put quotes and the tag around $link's value.

$link = "<script>window.open(\"https://secure.brosix.com/webclient/?nid=4444&user=$name&pass=$pass&hideparams=1width=710,height=555,left=160,top=170'\")</script>";



回答3:


you dont have to use php you just create submit button with specific id and then tell jquery to trigger new tab when submit

<form id="itemreport_new" type="post" action="">
          <input id="submit2" type="submit" value="show"  target=_blank   />
</form>

    $(document).ready(function () {


        $('#submit2').click(function() {
                 $('#itemreport_new').attr('target','_blank');
        });
    });



回答4:


<?php
echo "<h1>Hello, PHP!</h1>";
$name = $_POST['name']; // CONTAIN NAME OF PERSON
$pass = $_POST['pass']; // ANY DETAIL OF PERSON
$link = "<script>window.open('https://google.co.in')</script>";
echo $link;


来源:https://stackoverflow.com/questions/12291523/open-new-window-with-php-code-after-form-submits-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!