HTML表单PHP提交不起作用

6

我正在为自己写一个小网站,但是有一个看起来很简单的代码行让我很困扰:

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>

3
它为何无法正常工作? - Chris
你的send.php脚本文件长什么样子? 顺便说一下,你不能将google.com用作你的操作。这听起来像是你的send.php文件设置不正确。 - Michael Mikhjian
你能否贴出send.php代码呢?另外,你的html写得有些糟糕。应该是<br />而不是</br>,HTML5中只需写<br>即可。你的表单元素没有"value"属性。你的表单没有ID,这可能不太重要,但它应该有一个。如果是XHTML,至少应该有一个fieldset来使其“合规”。此外,input标签为自闭合,所以需要删除 </input> 标签。 - Kai Qing
3个回答

6

错误始于您的body标签。
您在body标签的style标签中没有关闭双引号。
只需正确关闭它,然后运行它。
我认为这只是问题所在。


1

这是一个应该能正常工作的表单:

<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


-1

当您的操作涉及到外部资源时,浏览器会显示警告。有些浏览器根本不会提交表单。这对用户来说是不安全的。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接