【问题标题】:HTML form PHP post not workingHTML表单PHP帖子不起作用
【发布时间】:2011-12-30 01:20:49
【问题描述】:

我正在为自己编写一个小网站,但我遇到了看似简单的代码行的问题:

form action="send.php" method="post"

此外,即使像form action="http://www.google.com"> 这样的简单行也不起作用。这是我的代码:

<html>  
    <head>  
        <title>  
            AnonMail!  
        </title>  
    </head>  
    <body style="font-family:'Tahoma';>  
        <form action="send.php" method="post">  
            <label for="from">From:  </label><input type="text" name="from" id="from"></input></br>  
            <label for="to">To:  </label><input type="text" name="to" id="to"></input></br>  
            <label for="subj">Subject:  </label><input type="text" name="subj" id="subj"></input></br>  
            <textarea rows=10 cols=100 name="message"></textarea></br>  
            <input type="submit" value="Send"/>  
        </form>  
    </body>  
</html>

【问题讨论】:

  • 在什么情况下不工作?
  • 您的 send.php 脚本文件是什么样的?顺便说一句,您不能使用 google.com 作为您的操作。听起来您的 send.php 文件必须设置不正确。
  • 发布您的 send.php 代码怎么样?此外,您那里有一些简单的坏 html。它是
    ,而不是 ,在 html5 中只是
    。您的表单元素中没有“值”属性。您的表单没有 ID,这无关紧要,但应该如此。如果它是 xhtml,它应该至少有一个字段集是“有效的”。此外,输入是自动关闭的。摆脱 标签

标签: php html forms post form-submit


【解决方案1】:

错误从您的正文标签开始。
您还没有在正文的样式标记中关闭双引号。
只需正确关闭它,然后运行它。
我认为这只是问题所在。

【讨论】:

    【解决方案2】:

    这是一个应该可以工作的表单:

    <html>
    <body>
    <form action="contact.php" method="post">
    <p><b>Your Name:</b> <input type="text" name="yourname" /><br />
    <b>Subject:</b> <input type="text" name="subject" /><br />
    <b>E-mail:</b> <input type="text" name="email" /><br />
    Website: <input type="text" name="website"></p>   
    <p><input type="submit" value="Send it!"></p>
    </form>
    </body>
    </html>
    

    如果您仍有问题:http://myphpform.com/php-form-not-working.php

    【讨论】:

      【解决方案3】:

      当您的操作引用外部来源时,浏览器会显示警告。有些浏览器根本不发布表单。这对用户来说是不安全的。

      【讨论】:

        猜你喜欢
        • 2012-05-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多