面对错误 - PHP中未定义的变量错误

时间:2015-12-05 18:24:07

标签: php

我是PHP的新手,我在从一本书中练习PHP时遇到了这个问题 -

这是HTML代码

        <form method="post" action="handle_post.php">
        		<p>First Name:  <input type="text" name="first_name" size="20"></p>
                <p>Last Name: <input type="text" name="last_name" size="20"></p>
                <p>Email Address: <input type="email" name="email" size="30"></p>
                <p>Posting: 
                						<textarea name="posting" rows="5" cols="40">
                                        </textarea>
                 </p>
                <input type="submit" name="submit" value="Send My Fucking Email">                 
        </form>

这是PHP代码..当我试图让它工作时,它说这行中有问题 -

$ posted

我在这里粘贴代码..让我知道它有什么问题

<?php

        date_default_timezone_set('Africa/Lagos');
        $first_name = $_POST['first_name']; 
        $last_name = $_POST['last_name']; 
        $posting =  $_POST['posting']; 
        $email = $_POST['email']; 

        $fullname = $first_name . ' ' . $last_name; 

        print "<div>Thank you my lord - $name, for your kind posting in this thread. This is the excerpt of the post: 
                    <p>$posting</p>
                    </div>";


        $fullname = urlencode((binary) $fullname); 
        $email = urlencode((binary) $email); 

        print "<p>Click <a href=\"thanks.php?name=$name&email=$email\">Here</a> to continue. </p>"; 



?>

2 个答案:

答案 0 :(得分:1)

您使用未声明的变量$ name:

print "<div>Thank you my lord - $name, for your kind posting in this thread. This is the excerpt of the post: 
                <p>$posting</p>
                </div>";

答案 1 :(得分:0)

使用此类变量时,将print变为echo