简单的联系表不起作用



我正在尝试制作简单的联系表格,我有两个文件,contact.php和index.php

我希望将几个选项出现在我的index.php文件中"查询类型"中的"我在contact.php文件中放入的那些选项:

<?php
class Contact{
	public static $types = array(
    1 => 'Product enquiry',
    2 => 'Billing enquiry',
    3 => 'Support enquiry'
		);
}

我还包括contact.php in index.php文件:

<?php require_once('file:///D:/Simple%20Contact%20Form/Liberay/Contact.php'); ?>

但是经过大量尝试,我看不到下拉字段的任何选项,所以可能是连接的东西吗?当我尝试使用PHP代码时,我是否应该将其放在XAMPP的本地服务器中?

这是index.php的完整代码:

<?php require_once('file:///D:/Simple%20Contact%20Form/Liberay/Contact.php'); ?>
<!DOCOTYPE html>
<html>
<head>
 <meta charset="utf-8" />
 <meta name="viewport" content="width=device-width" />
 <title>Simple contact form with PHP</title>
 <link rel="stylesheet" type="text/css" href="file:///D:/Simple%20Contact%20Form/CSS/core.css"/>
</head>
<body>
<form method="post" id="formContact" class="large-8 large-centered columns custom">	
<fieldset>
<legend>Simple Contact Form with PHP</legend>
<div class="large-6 columns">
	<label for="first_name">First name: *</label>
	<input 
	type="text"
	name="first_name"
     id="first_name"
     placeholder="Your first name"/>
 </div>
 <div class="large-6 columns">
	<label for="last_name">Last name: *</label>
	<input type="text"
	name="last_name"
     id="last_name"
     placeholder="Your last name"/>
 </div>
 <div class="large-6 columns">
	<label for="first_name">Email address: *</label>
	<input type="email"
	name="email"
     id="email"
     placeholder="Your Email address"/>
 </div>
<div class="large-6 columns">
	<label for="type">Enquiry type: *</label>
	<select
	 name="type"
	  id="type">
    
    <option value="">Select one</option>
   <?php if (!empty(Contact::$types)) { ?>
   <?php foreach(Contact::$types as $id => $type) { ?>
   <option value="<?php echo $id; ?>"><?php  echo $type; ?></option>
   <?php } ?>
    </select>
</div>
<div class="large-12 columns">
	<label for="enquiry">Enquiry: *</label>
	<textarea name="enquiry" id="enquiry" placeholder=" Your message"></textarea>
</div>
<div class="large-12 columns">
<button class="button small">Send message</button>
	</div>
</fieldset>
</form>
<script src="file:///D:/Simple%20Contact%20Form/jquery.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="file:///D:/Simple Contact Form/js/core.js"></script>
</body>

</html>

*对不起,如果有些混乱,但是我正在尽力而为( - :

如果您正在使用XAMPP,则将所有文件放在 htdocs 文件夹下。您已经提到

<?php require_once('file:///D:/Simple%20Contact%20Form/Liberay/Contact.php'); ?>

- 指的是本地文件路径。

最新更新