我很想啓動我的網站,但首先我需要完成我的聯繫表單,以確保用戶可以與我聯繫。我不是PHP專家或任何接近的專家,所以請理解我的無知。聯繫表格,它是如何工作的?
我準備好並運行了我的服務器。我有一封電子郵件。我有這個網站。我有兩個文件,一個是contact.html
,另一個是send.php
。
我contact.html
有以下內容:
<!doctype html>
<html>
<head>
<title>Spotnight - About</title>
<link rel="stylesheet" href="style.css">
<link rel="Favicon" href="f.ico" type="image/x-icon">
</head>
<body>
<div class="ham_container">
<svg id="hamburger" title="Menu">
<path d="M0,5 30,5" stroke="#eeeeee" stroke-width="5"/>
<path d="M0,14 30,14" stroke="#eeeeee" stroke-width="5"/>
<path d="M0,23 30,23" stroke="#eeeeee" stroke-width="5"/>
</svg>
</div>
<nav>
<ul>
<li><a href="http://spotnight.io/">Our Home</a></li>
<li><a href="http://spotnight.io/about.html">About Us</a></li>
<li><a href="http://spotnight.io/hybon.html">Hybon Sites</a></li>
<li><a href="http://spotnight.io/orion.html">Orion Interactives</a></li>
<li><a href="http://spotnight.io/studios.html">Spotnight Studios</a></li>
<li><a href="http://spotnight.io/shop.html">Spotnight Shop</a></li>
<br>
<li><a href="http://spotnight.io/contact.html">Contact Us</a></li>
</ul>
</nav>
<main>
<h1>Contact us! :)</h1>
<h5>Spotnight</h5>
<div>
<form action="send.php" method="POST">
<input type="text" name="first_name" placeholder="Your first name, eg: 'John'">
<input type="text" name="last_name" placeholder="Your last name, eg: 'Smith'">
<input type="email" name="email" placeholder="Your Email, eg: '[email protected]'">
<select name="subj" size="1">
<option value="new_website">I need a website</option>
<option value="new_game">I want a game</option>
<option value="new_employee">I want to be part of the team</option>
<option value="new_employee_game">I want to participate making games</option>
<option value="new_employee_site">I want to participate building sites</option>
<option value="new_artist">I'm an artist and need help</option>
<option value="something_else">Something else!</option>
</select>
<textarea name="message" placeholder="Your Message Goes Here!"></textarea>
<input type="submit" value="Send!">
</form>
</div>
</main>
<footer>
© <span id="year">2015</span> : <a href="http://hybon.spotnight.io/">Spotnight.io</a> : Proudly created by Hybon.
</footer>
</body>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="script.js"></script>
</html>
我send.php
文件有以下內容:
<!doctype html>
<html>
<head>
</head>
<body>
<?php
$first_name = $_POST["first_name"];
$last_name = $_POST["last_name"];
$email = $_POST["email"];
$subj = $_POST["subj"];
$message = $_POST["message"];
$formcontent="From: " . $first_name . $last_name . ", " . $email . "\n Subject: " . $subj . "\n Message: " . $message;
$recipient = "[email protected]";
$subject = "Contact Form - " . $subj . " - Spotnight.io";
$mailheader = $email . " has tryed to reach you! \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You! Your message has been recived, we'll answer as soon as possible!" . $first_name . $last_name . " -" . "<a href="contact.html">Go Back!</a>";
?>
</body>
</html>
這是所有的文字,這意味着,該代碼是完全一樣的在那裏。我無法理解它,但我仍然不明白它是如何工作的。
所以,如果你是一個超級可怕的php專家,請幫助我理解並修復此代碼,以便稍後處理它,以便其他人瞭解它是如何工作的。
我已經搜索了很多地方,但最簡單的聯繫表格形式並沒有出現在世界檔案中。非常感謝你!
它。看起來像一個簡單的錯誤,在你的$ formcontent行中,你用$ message「」結束它;刪除「,所以它看起來像這樣:$ message; – Epodax 2015-03-03 10:59:48
謝謝,我沒有看到,但即使我已經更新它,它似乎仍然不工作,它只是給我一個空白頁面'send.php' – 2015-03-03 11:02:08
@ julian.a.avar - 這聽起來像你的服務器不支持PHP。 – Quentin 2015-03-03 11:02:50