这曾经有用,但现在它不会发送用户输入,只是消息:电子邮件:名称:等。 PHP应该工作,我认为它可能无法检索HTML?
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$to="fakeemail@sorry.com";
$subject="Tech Muffins Contact";
$message="Name: ".$_REQUEST['name']."\n\nEmail: ".$_REQUEST['email']."\n\nMessage: ".$_REQUEST['message'];
mail($to, $subject, $message, $from );
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Tech Muffins</title>
<link rel="shortcut icon" href="icon.ico" />
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="techmuffins.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script>
<script src="virus_min.js" type="text/javascript"></script>
<script src="hide.js"></script>
</head>
<body>
<div id="header"></div>
<div id="content">
<ul id="menu">
<a href="">
<li id="page">Home</li>
</a>
<a href="#">
<li id="contact">Contact
<form id="contactform" action="" method="post" autocomplete="off">
<input type="text" name="name" placeholder="name" autofocus required>
<input type="email" id="email" name="email" placeholder="email" required>
<textarea name="message" placeholder="message" required></textarea>
<input type="submit" value="submit"></input>
</form>
</li>
</a>
</ul>
<div id="currentvid">
<iframe src="http://www.youtube.com/embed/NlB4g1IR0nQ?&iv_load_policy=3&rel=0"></iframe>
</div>
<h1 id="title">1. Create Billboard</h1>
<div id="videos">
<ul id="videomenu">
<a href="NlB4g1IR0nQ" class="youtube">
<li id="active">1. Create Billboard</li>
</a>
<a href="DmLffEwMIDA" class="youtube">
<li>2. Illustrator Tutorial</li>
</a>
<a href="PhlTstOPF3c" class="youtube">
<li>3. Remote Server</li>
</a>
<a href="nmeJrM30pz0" class="youtube">
<li>4. Brush Presets</li>
</a>
<a href="N7HldTtKYUg" class="youtube">
<li>5. Audio Editing</li>
</a>
<a href="uq3worB22eM" class="youtube">
<li>6. Background Editing</li>
</a>
<a href="Px29iXqYQIc" class="youtube">
<li>7. PHP Theme Change</li>
</a>
<a href="L6bBsrA4xRo" class="youtube">
<li>8. Photoshop Tutorial</li>
</a>
<a href="2S8kysshs2A" class="youtube">
<li>9. Flash Shape Tween</li>
</a>
<a href="b78XC2LE8bE" class="youtube">
<li>10. Shiny Text Tutorial</li>
</a>
<a href="dZMVmaxPgCM" class="youtube">
<li>11. HTML5 Canvas</li>
</a>
<a href="9vLnfWT9wQ8" class="youtube">
<li>adorable.</li>
</a>
<a href="_OBlgSz8sSM" class="youtube">
<li>Charlie Bit My Finger</li>
</a>
<a href="9bZkp7q19f0" class="youtube">
<li>Gangnam Style</li>
</a>
<a href="1f4AhcX3EyI" class="youtube">
<li>MTCHS Harlem Shake</li>
</a>
<a href="AKuBMihmVHQ#t=24s" class="youtube">
<li>Mystery</li>
</a>
<a href="DKWdSCt4jGE#t=14s" class="youtube">
<li>Stop Motion</li>
</a>
<a href="feCXr86HzMk" class="youtube">
<li>DOG</li>
</a>
</ul>
</div>
</div>
<div id="alert">Thank you for visiting my page. It was created with lots of love and frustration. To exit this alert, click on the footer or press escape. Or simply delete system32; that works too.</div>
<div id="footer">© Josue Espinosa 2013</div>
</body>
</html>
有人可以指出我正确的方向,如何发送电子邮件或为什么它不起作用?
答案 0 :(得分:1)
<?php
if (isset($_POST)){
$to = "someone@example.com";
$subject = "Test mail";
$message = "Name: ".$_POST['name']. "\r\n Email: ".$_POST['email']. "\r\n Message: ".$_POST['message'];
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
}