0

我在本地网站上工作,我正在尝试向其中添加联系表格。

我在: 上添加了一个简单的表单http:localhost:8888/testsite/contact.php,当用户单击提交按钮时,我希望他们被重定向到另一个带有消息的页面。我希望用户在提交表单后转到的页面:contact_message.php.

我已经创建了这两个文件,并且它们都在 URL 上显示 OK -http:localhost:8888/testsite/contact.php但是http:localhost:8888/testsite/contact-message.php表单无法正常工作,因为当您单击提交时,url 更改为:http:localhost:8888/testsite/contact.php/contact-message.php,如果它显示contact-message.php内容会很好,但它没有。

表格前的代码是:

<form method="post" action="contact-message.php">
    <table>
        <tr>
            <th>
                <label for="name">Name</label>
            </th>
            <td>
                <input type="text" name="name" id="name">
            </td>
        </tr>
        <tr>
            <th>
                <label for="email">Email</label>
            </th>
            <td>
                <input type="text" name="email" id="email">
            </td>
        </tr>
        <tr>
            <th>
                <label for="message">Message</label>
            </th>
            <td>
                <textarea type="text" name="message" id="message"></textarea>
            </td>
        </tr>

    </table>

    <input type="submit" value="Send">

</form>

有人有什么想法吗?

4

3 回答 3

1

您需要在表单操作中添加正确文件的完整路径或相对路径。目前,您正在告诉表单提交到当前 url 和 contact-message.php。而是尝试...

<form method="post" action="http:localhost:8888/testsite/contact-message.php">

或者干脆..

<form method="post" action="/contact-message.php">

它告诉它使用基本 URL + /contact-message.php

于 2013-10-24T16:13:03.317 回答
0

如果您的发送邮件函数返回 true,请尝试使用此代码:

header("Location: http://localhost:8888/testsite/contact_message.php");

PHP 头文件: http: //php.net/manual/pt_BR/function.header.php

于 2013-10-24T16:11:48.237 回答
0

尝试将表单标签替换为:

<form method="post" action="./contact-message.php">

然后这将调用位于同一文件夹中的contact-message.php 文件。点是从当前位置开始的开始 fa 相对路径

于 2013-10-24T16:12:39.700 回答