无法以联系人形式显示php变量

时间:2016-03-14 21:12:15

标签: php

我正在尝试创建联系表单。我想在h1下方显示$ result,但我收到以下通知:

  

注意:未定义的索引:在第4行的C:\ xampp \ htdocs \ contact-form \ contact.php中提交

     

注意:未定义的变量:在第48行产生C:\ xampp \ htdocs \ contact-form \ contact.php

以下是截图:https://www.dropbox.com/s/ltoc8j3j6iyppc5/Screenshot%202016-03-14%2014.14.19.png?dl=0

第4行是:

    if ($_POST["submit"]) {

任何人都可以提供通知的线索吗?

<?php
$result="test";

    if ($_POST["submit"]) {

        $result="Form submitted";

    }

?>

<!DOCTYPE html>
<html>
<head>
    <title>Contact Form</title>
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

<style>

    .emailForm {
        border:1px solid gray;
        border-radius:10px;
        margin-top:20px;
    }

    textarea {
        height:120px;
    }

    form {
        padding-bottom:20px;
    }

</style>

</head>
<body>
<div class="container">

    <div class="row">
        <div class="col-md-6 col-md-offset-3 emailForm">
            <h1>My email form</h1>

            <?php echo $result; ?>

            <p class="lead">Please get in touch - I'll get back to you as soon as I can!"</p>

            <form method="post">

                <div class="form-group">

                    <label for="name">Your Name:</label>
                    <input type="text" name="name" class="form-control" placeholder="Your Name"/>

                </div>

                <div class="form-group">

                    <label for="name">Your Email:</label>
                    <input type="email" name="email" class="form-control" placeholder="Your Email"/>

                </div>

                <div class="form-group">

                    <label for="name">Your Comment:</label>
                    <textarea class="form-control" name="comment"></textarea>

                </div>
                <input type="submit" name="submit" class="btn btn-success btn-lg" value="Submit"/>
            </form>

        </div>
    </div>

</div>

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>

谢谢,感谢任何帮助。

0 个答案:

没有答案
相关问题