我的PHP文件在網站的根文件夾中不起作用。如果它位於另一個文件夾中,稱爲「無論」,它就會起作用但它不會在根文件夾中工作。這是一個空白的白頁。PHP文件在網站的根文件夾中不起作用
這是一個簡單的聯繫表單(contact.html)與contact.php
文件來處理表單。我總是把它們放在一起放在同一個文件夾中。它不會在根中工作。
Contact.php文件:
<?php
$subject = $_POST['sub'];
$name = $_POST['name'];
$from = $_POST['email'];
$message = $_POST['msg'];
$to = "[email protected]";
$send_email = mail($to,$subject,$message);
if($send_email){
echo "Your message is successfully sent!!!";
}
else{
echo "Error in sending contact email!!!";
}
?>
新增contact.html的要求:
<html>
<body>
<table>
<form name="contact_form" method="post" action="contact.php">
<tr>
<td><b>PHP Contact Form</b></td>
</tr>
<tr>
<td>Subject</td>
<td><input name="sub" id="sub" type="text" size="75"></td>
</tr>
<tr>
<td>Name:</td>
<td><input name="name" id="name" type="text"></td>
</tr>
<tr>
<td>Email</td>
<td><input name="email" id="email" type="text"></td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="msg" cols="60" rows="5" id="msg"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit">
</tr>
</form>
</table>
</body>
</html>
.htaccess文件
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
# Adaptive-Images ------------------------------------------------------------------ -----------------
# Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
# RewriteCond %{REQUEST_URI} !some-directory
# RewriteCond %{REQUEST_URI} !another-directory
RewriteCond %{REQUEST_URI} !assets
# Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
# to adaptive-images.php so we can select appropriately sized versions
RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php
# END Adaptive-Images -------------------------------------------------------------------------------
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
所以代碼在一個地方找到,而不是其他地方。所以可以得出結論,問題不在於代碼(即毫無意義的發佈),而是與Web服務器的配置有關。 'htaccess'等也許? –
你可以把你的html代碼以及pls? – Antoine
你能從'html'文件中顯示你的'