Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP查询无法使用表单_Php_Mysql_Forms - Fatal编程技术网

PHP查询无法使用表单

PHP查询无法使用表单,php,mysql,forms,Php,Mysql,Forms,这是我对插入的查询: <?php require_once "config.php"; if(isset($_POST['submit'])){ $email = mysql_escape_string($_POST['txtemail']); $str = "insert into subscribe(email,datetime) values ('$email',current_timestamp)"; $result = mysql_qu

这是我对插入的查询:

<?php
    require_once "config.php";
    if(isset($_POST['submit'])){

    $email = mysql_escape_string($_POST['txtemail']);

    $str = "insert into subscribe(email,datetime) values ('$email',current_timestamp)";
    $result = mysql_query($str);

    print '<script type="text/javascript">';
            print 'alert("Thank you for subscribing with us. We will be in touch with you very soon.")';
            print '</script>';  


}
上面的代码工作得很好,但当我在表单操作上输入一个值以重定向到另一个类似这样的页面时,查询并没有插入

<form action="/?sender=nopopup" method="POST">
我尝试使用headerlocation:'url',但它也不起作用。 任何帮助都将不胜感激,谢谢

这是我的全部代码:

<html>
<head>
<title>Chill PH</title>
<link rel="stylesheet" type="text/css" href="style/style.css" media="screen">
<link rel="stylesheet" type="text/css" href="style/main.css" media="screen">
<link rel="stylesheet" href="images/default/default.css" type="text/css" media="screen" />

<link rel="stylesheet" type="text/css" href="style/popup.css" media="screen">
<script type="text/javascript" src="jQuery/popup.js"></script>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

</head>

<div id="overlay"></div>

<center>
<div id="popup">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?sender=nopopup" method="POST">
<table style="background-color:#FFFFFF;">
<tr>
<a href="#" onclick="closePopUp()"><img src="images/popup/chill_closebtn.png" style="width:30px; height:30px; vertical-align: top; 
margin-left: 583px; margin-top: -12px; position:fixed;"/></a>
    <img src="images/popup/chill_popup.jpg"/>
</tr>
<tr>
    <td style="width: 594px; height: 111px;">
        <input id="txtemail" type="email" font-size= "12px" name="txtemail" placeholder="E-mail Address" 
        style="background-color:#f1c4c0; border-style:none; height:40px; width:270px; margin-left:60px; border-style:none; font-size: 15px;" required/>
        <input type="submit" id="subcribe_button" name="submit" value="Subscribe" />
    </td>
</tr>
</table>
</form>
</div>
</center>

<body onload="showPopUp()">
<center>
<div id="container">
    <table id="header">
        <tr>
            <td>
                <center>
                    <div id="logo" style="color: #ff0000;">
                        <a href="/?sender=nopopup"><img src="images/logo.png" alt="Chill" style="width: 130px;" /></a>
                    </div>
                </center>
            </td>        
            <td style="float: left; width: 15px; padding-right: 15px;">
                <div id="searchbox">
                    <form name="frmsearch" method="POST" action="/?sender=result">
                    <input type="text" id="search" name="search" size=20 placeholder="Search" style="background-color: white; float: right; color: black; border: 1px solid #000;"/>
                    <input type="submit" id="submit" name="submit" value="Search" style="display: none;visibility: hidden;" />
                    </form>
                </div>
            </td>
        </tr>
        <tr>                    
            <td align='center'>
                <div id="main-nav">
                    <ul>
                        <li style="padding-left: 50px; padding-right: 40px;"><a href="#">WHAT'S HOT<span class="drop-down"></span></a>
                            <ul>
                                <li class="shopitems"><a href="/?sender=shop&category=newarrivals">New Arrivals</a></li>
                                                                    <li class="shopitems"><a href="/?sender=shop&category=sale">Sale Items</a></li>
                            </ul>
                        </li>
                        <li style="padding-left: 40px; padding-right: 40px;"><a href="#">COLLECTION<span class="drop-down"></span></a>
                            <ul>
                                <li class="shopitems"><a href="/?sender=shop&category=DRESS">Dresses</a></li>
                                <li class="shopitems"><a href="/?sender=shop&category=TOPS">Tops</a></li>
                                <li class="shopitems"><a href="/?sender=shop&category=SKIRTS">Skirts</a></li>
                            </ul>
                        </li>
                        <li style="padding-left: 30px; padding-right: 30px;"><a href="/?sender=lookbook" class="lookbook">LOOKBOOK</a></li>
                        <li style="padding-left: 30px; padding-right: 30px;"><a href="/?sender=news">NEWS</a></li>
                        <li style="padding-left: 40px; padding-right: 30px;"><a href="/?sender=store">STORES</a></li>
                    </ul>
                </div>
            </td>
        </tr>
    </table>


<?php
    require_once "config.php";
    if(isset($_POST['submit'])){

    $email = mysql_escape_string($_POST['txtemail']);

    $str = "insert into subscribe(email,datetime) values ('$email',current_timestamp)";
    $result = mysql_query($str);

    print '<script type="text/javascript">';
            print 'alert("Thank you for subscribing with us. We will be in touch with you very soon.")';
            print '</script>';  


    }
?>  
应该是:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>?sender=nopopup" method="POST">

/正在将其发布到您网站的根目录,而不是当前URL。包含当前脚本相对于文档根目录的路径。

对不起,先生,它不起作用,警报框也不显示感谢您的帮助,先生,但它也不起作用,我编辑了我的问题并放入了我的全部代码。也许这也会有帮助,对不起,我刚刚接触php和web编程。