我有一个不想在我的浏览器上打开的php文件,我将它保存在xammp / htdoc文件夹中,当我尝试在浏览器中打开它时,我可以选择保存或打开文件。
这是我的代码:
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("my_email_address@yahoo.com", $subject,
$message, "From:" . $email);
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='sch.php'>
Email: <input name='email' type='text'><br>
Subject: <input name='subject' type='text'><br>
Message:<br>
<textarea name='message' rows='15' cols='40'>
</textarea><br>
<input type='submit'>
</form>";
}
?>
</body>
</html>
答案 0 :(得分:3)
您需要通过本地网络服务器访问该文件,以便可以解释php。
如果appache正在侦听端口80 localhost,那么您的浏览器中必须有这样的URL:
localhost/yourfile.php
不是
file:///C:/xampp/htdocs/yourfile.php