执行PHP代码后关闭窗口

时间:2023-01-20 17:04:04

Hey Guys so I have two problems

嘿伙计,所以我有两个问题

  1. How do I close the window once I Have executed my PHP code which is a simple save textbox values to database?

    一旦我执行了PHP代码,这是一个简单的保存文本框值到数据库,如何关闭窗口?

  2. How do I get my text boxes to align so they perfectly aligned currently one is more indented than the other DEMO?

    如何让我的文本框对齐,以便它们完美对齐,目前一个比其他DEMO更缩进?

Here's the PHP code that saves data into my database once saved I want the current window to close:

这是保存数据后将数据保存到我的数据库中的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>';
}
?>

2 个解决方案

#1


4  

For first part -

第一部分 -

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

For second part, place this on server side code-

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

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

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

#2


4  

Try window.close() of JavaScript:-

试试JavaScript的window.close(): -

<?

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();

    echo  "<script type='text/javascript'>";
    echo "window.close();";
    echo "</script>";
} else {
    echo '<h4>One Field Is Required!</h4>';
}

?>

#1


4  

For first part -

第一部分 -

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

For second part, place this on server side code-

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

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

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

#2


4  

Try window.close() of JavaScript:-

试试JavaScript的window.close(): -

<?

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();

    echo  "<script type='text/javascript'>";
    echo "window.close();";
    echo "</script>";
} else {
    echo '<h4>One Field Is Required!</h4>';
}

?>