定位警告消息時發生問題(您需要填寫所有必填字段!!等)不能通過CSS來完成,因爲這些元素沒有任何位置。如何使用Javascript放置我的PHP接觸形式警報消息?
任何想法?
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf8" />
<link rel="stylesheet" type="text/css" media="all" href="css/mainstyle.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="js/everypage.js"></script>
<meta name="viewport" content="initial-scale=1" />
<link rel="shortcut icon" href="IMG/tabicon/favicon.ico" >
<title> A band </title>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Website';
$to = '[email protected]';
$subject = 'Hello';
$human = $_POST['human'];
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<p class="alert">Your message has been sent!</p>';
} else {
echo '<p class="alert">Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p class="alert">You answered the anti-spam question incorrectly!</p>';
}
} else {
echo '<p class="alert">You need to fill in all required fields!!</p>';
}
}
?>
</head>
<body>
<div id="background">
<div id="wrapper">
<div class="navigation">
<ul id="mainmenu">
<li><a href="index.html">Home</a></li>
<li><a href="band.html">Band</a></li>
<li><a href="news.html">News</a></li>
<li><a href="shows.html">Shows</a></li>
<li><a href="music.html">Music</a></li>
<li><a href="gallery.html">Gallery</a></li>
<li><a href="media.html">Media</a></li>
<li><a href="store.html">Store</a></li>
</ul>
</div>
<div class="article">
<div id="logo"></div>
<div class="contacts">
<h1> Contact, booking:</h1>
<p> [email protected] </p>
<p> Tel: +372 58 131 054</p>
</div>
<form method="post" action="contact.php">
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" type="email" placeholder="Type Here">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<input id="submit" name="submit" type="submit" value="Submit">
<label>*What is 2+2? (Anti-spam)</label>
<input name="human" placeholder="Type Here">
</form>
</div>
</div>
<div class="footer contactfooter">
<p class="bandmembers">content</p>
<p class="signature">content</p>
<ul id="footermenu">
<li><a href="terms.html">Terms of use</a></li>
<li><a href="privacy.html">Privacy Policy</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
在一個不相關的字條:「佔位符=‘請在此處鍵入’」在大多數情況下 – andy