php 表单提交结果后用php代码打开新窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12291523/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:15:47  来源:igfitidea点击:

open new window with php code after form submits results

phpformsvalidationpopupwindow

提问by Link

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.

我这样做对吗,我想在用户将表单提交给 php 代码后打开一个弹出窗口,但我总是收到错误消息。

回答by Deepak

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 fancyboxwhich can load webpages as a whole in a popup window using iframes. There are other options as well feel free to explore!

您应该考虑使用fancybox,它可以使用iframe 在弹出窗口中整体加载网页。还有其他选择也可以随意探索!

回答by Alex Fischer

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

你忘了在 $link 的值周围加上引号和标签。

$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>";

回答by user1080247

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

您不必使用 php,您只需创建具有特定 id 的提交按钮,然后告诉 jquery 在提交时触发新选项卡

<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');
        });
    });

回答by Abhishek TN

<?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;