我的联系表格不起作用

时间:2014-04-21 13:41:39

标签: php html forms contact

我按照教程制作了一份联系表格。也将它上载到wamp上以进行测试。但我仍然遇到错误,但我真的无法找到错误。也许是因为我不知道PHP。有人可以检查我的代码,让我知道问题。我认为这个问题非常小。谢谢。

<!DOCTYPE HTML>
        <html>

        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <link rel="stylesheet" href="index.css">
            <title>Contact Form</title>
        </head>

        <body>

            <header class="body">
            </header>

            <section class="body">
                <?php
                $name = $_POST['name'];
                $email = $_POST['email'];
                $message = $_POST['message'];
                $from = 'From: TangledDemo'; 
                $to = 'aijaz@techanipr.com'; 
                $subject = 'Hello';

                $body = "From: $name\n E-Mail: $email\n Message:\n $message";
                ?>


                <?php
                if ($_POST['submit']) {
                    if (mail ($to, $subject, $body, $from)) { 
                        echo '<p>Your message has been sent!</p>';
                    } else { 
                        echo '<p>Something went wrong, go back and try again!</p>'; 
                    }
                }
                ?>
                <form method="post" action="index.php">

                    <label>Name</label>
                    <input name="name" placeholder="Type Here">

                    <label>Email</label>
                    <input name="email" type="email" placeholder="Type Here">

                    <label>Message</label>
                    <textarea name="message" placeholder="Type Here"></textarea>

                    <input id="submit" placeholder="Type Here" name="Submit" type="submit" value="Submit">

                </form>
            </section>

            <footer class="body">
            </footer>



        </body>

        </html>

1 个答案:

答案 0 :(得分:3)

你的if($_POST['submit'])有一个小写的“s”,它应该是一个大写字母“S”。