这是index.php:

 header('Location:media.php?module=home');

我称之为media.php:
    <html>
    <head>
    <title>Test media</title>
    </head>
    <body>
    <table width="960"  border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td colspan="2"><img src="images/cms/header.png" width="780" height="77"></td>
    </tr>
    <tr>
     <td width="200" valign="top" bgcolor="#1e2528">
     <?php include "menu.php"; ?>
     <p align="center">&nbsp;</p>
      </td>
      <td width="760" valign="top" bgcolor="#FFFFFF">
      <p>
      <?php include "content.php"; ?>
       <br>
      </p>
      </td>
      </tr>
   </table>
</body>
</html>

这就是问题所在,content.php:
   <table width="100%" cellspacing=5>
    <?php
    include_once 'include/config.php';
    include_once 'admin/include/date_lib.php';
    include_once 'class/class_lib.php';
    include_once 'class/paging.php';
    $action = new DB();
    $action->db_connect();



 if ($_GET[module]=='home'){
     </td></tr>";
      echo "<tr><td align=center>Headline News<br><br></td></tr>";
    elseif ($_GET[module]=='request'){
      echo "<tr><td class=judul_head>&#187; Hubungi Kami</td></tr>";

      echo "<tr><td class=isi>Silahkan hubungi kami secara online:</td></tr>";

      echo "<form action='?module=sendemail' method='post'>
            <tr><td class=isi>Name   : <input type=text name=name size=35></td></tr>
            <tr><td class=isi>E-mail : <input type=text name=email size=35></td></tr>
            <tr><td class=isi>Subject: <input type=text name=subject size=50></td></tr>
            <tr><td class=isi>Message  : <br><textarea name=message rows=13 cols=70>

</textarea></td></tr>
            <tr><td><input type=submit value=Send></td></tr>
            </form>";

        echo "<tr><td class=back><br>
            [ <a href=javascript:history.go(-1)>Back</a> ]</td></tr>";
    }




  elseif ($_GET[module]=='sendemail'){
      mysql_query("INSERT INTO email(name,
                                       email,
                                       subject,
                                       message,
                                       date)
                            VALUES('$_GET[name]',
                                   '$_GET[email]',
                                   '$_GET[subject]',
                                   '$_GET[message]',
                                   '$today_date')");



 echo "<tr><td class=header_head>&#187; Status Email</td></tr>
        <tr><td class=isi>Email has been sent</td></tr>
        <tr><td class=back><br>
        [ <a href=index.php>Back</a> ]</td></tr>";
}

我有一个使用post方法的电子邮件表单。但是当我点击提交按钮时
在url地址栏上会是这样的
http://staging/media.php?name=Test+name&email=Test+email&subject=test+subject&,message=Test+message

就像我用get方法一样。但如果在查询时将$_POST更改为$_GET。它不起作用。
我的剧本少了什么吗?还是因为我使用$_GET[module]方法在同一页上调用?

最佳答案

if ($_GET[module]=='home'){ </td></tr>";
在我看来,你好像漏掉了echo "语句。

关于php - 为什么POST和GET方法Form在PHP上不起作用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10394560/

10-09 05:33
查看更多