禁止PHP项目访问

时间:2014-06-18 21:14:45

标签: php

我正在尝试学习如何使用PHP发送电子邮件,而我所获得的建议令人沮丧。它想要学习如何驾驶棍子,但被告知如何加工零件来制造变速器。我的代码是

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Contact Blackjack Trainer</title>
    <link type="text/css" rel="stylesheet" href="css/blackjack.css" />
</head>
<body>
    <?php
        function spamcheck($field)
        {
            // Sanitize e-mail address
            $field=filter_var($field, FILTER_SANITIZE_EMAIL);
            // Validate e-mail address
            if(filter_var($field, FILTER_VALIDATE_EMAIL))
            {
                return TRUE;
            }
            else
            {
                return FALSE;
            }
        }
    ?>
    <h1>Blackjack Trainer Contact</h1>
    <?php
        // display form if user has not clicked submit
        if (!isset($_POST["submit"]))
        {
    ?>
    <form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>
    <fieldset>
        <legend>Your Contact Details</legend>
        <p>
            <label for="from">Name: <em>(required)</em></label>
            <input name="from" id="from" type="test" size="80" />
        </p>
        <p>
            <label for="subject">Subject:</label>
            <input name="subject" id="subject" type="text" size="80" />
        </p>
    </fieldset>
    <p>For defect reporting, please state dealer's hand, player's hand, options, and expected and actual outcomes.</p>
    <fieldset>
        <legend>Comments, Suggestions or Defect Reporting</legend>
        <p>
            <label for="message">Message: <em>(required)</em></label>
            <textarea name="message" id="message" cols="75" rows="20"></textarea>
        </p>
    </fieldset>
    <input type="submit" name="submit" value="Submit" />
    </form>
    <?php 
        }
        else
        // the user has submitted the form
        {
            echo "so far so good";
            // Check if the "from" input field is filled out
            if (isset($_POST["from"]))
            {
                // Check if "from" email address is valid
                $mailcheck = spamcheck($_POST["from"]);
                if ($mailcheck==FALSE)
                {
                    echo "Invalid input";
                }
                else
                {
                    $from = $_POST["from"]; // sender
                    $subject = $_POST["subject"];
                    $message = $_POST["message"];
                    // message lines should not exceed 70 characters (PHP rule), so wrap it
                    $message = wordwrap($message, 70);
                    // send mail
                    mail("normhines@hotmail.com",$subject,$message,"From: $from\n");
                    echo "Thank you for sending us feedback";
                }
            }
        }
    ?>
</body>

然而,当我点击提交时,我得到了#34; 403禁止:你没有权限访问/ blackjack /&lt;在这台服务器上。&#34;

如何获得访问我自己项目的权限?我需要安装邮件服务器吗?这只是我的开发平台;我还没有真正托管我的网站。

1 个答案:

答案 0 :(得分:0)