gpt4 book ai didi

javascript - 执行PHP代码后如何关闭窗口?

转载 作者:可可西里 更新时间:2023-11-01 00:09:11 25 4
gpt4 key购买 nike

我有两个问题:

  1. 执行 PHP 代码后如何关闭窗口,这是一个简单的将文本框值保存到数据库的方法?

  2. 如何让我的文本框对齐,以便它们完美对齐,当前一个比另一个缩进更多 DEMO

这是保存数据后将数据保存到我的数据库中的 PHP 代码 我想关闭当前窗口:

<form name="Permit" id="Permit" action="<?php echo JURI::current(); ?>" method="post">
Permit or Deny: <input align= center type="text" name="Permit_or_Deny" value=""><br>
Level <input type="text" name="Level" value=""><br>
<p><input id="submit" name="submit" type="submit" value="Permit Or Deny Submit Buutton" /></p>
</form>


<?
if ((isset($_POST['Permit_or_Deny'])) || (isset($_POST['Level']))) {
//first name or last name set, continue-->
$Permit_or_Deny = $_POST['Permit_or_Deny'];
$Level = $_POST['Level'];

$db =& JFactory::getDBO();
$query = "INSERT INTO tp_newedit (Permit_or_Deny, Level) VALUES ('" . $Permit_or_Deny . "','" . $Level . "');";

$db->setQuery($query);
$db->query();
} else {
echo '<h4>One Field Is Required!</h4>';
}
?>

最佳答案

第一部分-

<form name="Permit" id="Permit" action="<?php echo JURI::current(); ?>" method="post">

<div class="label" style="display:inline-block;width:200px"> Permit or Deny: </div><input align= center type="text" name="Permit_or_Deny" value=""/><br>
<div class="label" style="width:200px;display:inline-block;"> Level </div> <input type="text" name="Level" value=""><br>

<p><input id="submit" name="submit" type="submit" value="Permit Or Deny Submit Buutton" /></p>
</form>

对于第二部分,将其放在服务器端代码中-

<?php    
/* ... SQL EXECUTION TO UPDATE DB ... */

echo "<script>window.close();</script>";
?>

关于javascript - 执行PHP代码后如何关闭窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22347983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com