简体   繁体   English

我的联系表格不工作 html css

[英]My contact form is not working html css

Can someone explain why my contact form doesn't work?有人可以解释为什么我的联系表不起作用吗? I followed a tutorial and in the tutorial it did in fact work in the end and I can't get my head around this.我遵循了一个教程,在教程中它最终确实有效,我无法理解这一点。 Thank you for your anwsers in advance.提前感谢您的回答。

HTML HTML

<!doctype html>
<html>
<link href="contactcss.css" rel="stylesheet" type="text/css">
<body>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Contact</title>

<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="js/custom.js"></script>

</head>

<div class="logo" >
<img src="lg.png" alt="" width="180" height="178" class="logo"/>
</div>




<nav>
            <ul>
                <li><a href="projects.html" class="transition">PROJECTS</a>       </li>
                <li><a href="About.html" class="transition">ABOUT</a></li>
                <li><a href="Contact.html" class="transition">CONTACT</a></li>
            </ul>
        </nav>

<div id="wrap">
<div class="box1">
<form class="form">
<p class="name">
  <input type="text" name="name" id="name" />
  <label for="name">Name</label>
</p>
<p class="email">
  <input type="text" name="email" id="email" />
  <label for="email">E-mail</label>
</p>

<p class="text">
  <textarea name="text" placeholder="Your message here"></textarea>
</p>
<p class="submit">
  <input type="submit" value="send" />
</p>
</form>
</div> 
</div>
<footer>copyright 2016 matic toni</footer> <!--wrap-->
</body>
</html>

CSS CSS

@charset "utf-8";
.logo {
padding-top: 3px;
padding-bottom: 5px;
text-align: center;
}
ul {
padding: 0;
}
nav {
font-family: "Proxima";
text-align: center;
font-size: 25px;
word-spacing: 80px;
padding-right: 50px;
padding-bottom: 1%;
padding-left: 50px;
color: #000000;

}



li {
display: inline;
color: #000000;


}
a {
text-decoration: none;
color: black;
}

a:hover {
color: lightgray;
}
a:active {
color: black;
}

body {
margin: 0;
background-color: #F9F9F9;
font-family: Proxima;
}
#wrap {
width: 600px;
margin: 0 auto;
padding-top: 2%;
}

.box1 {
padding: 25px;
background-color: #F9F9F9;
border-radius: 2%;
box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
border: 3px solid black;
}

.form {
margin: auto; 
}

input, textarea {  
width: 200px;
padding: 9px;
outline: 0;        
background-color: #FFFFFF;
box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
border: 1px solid black;         
}

textarea {   
width: 530px; max-width: 530px; 
height: 150px; 
line-height: 150%;
font-size: 14px;
color: #D7D7D7;
} 

input:hover, textarea:hover,  
input:focus, textarea:focus {   
border-color: #C9C9C9;    
}

.text textarea:focus {
color: #000;
}

.form label {   
margin-left: 10px;   
color: #999999;   
}  

.submit input {  
width: 100px;  
padding: 9px 15px;    
font-size: 18px;  
color: #FFFFFF;
background-color: black;
border: 0;  
border-radius: 2px;
}

.submit input:hover {
cursor: pointer;
background-color: lightgray;
}

input {
font-family: Proxima;
}

@font-face {
font-family: Proxima;
src: url(Fonts/Proxima_Regular.otf);

} 
body {
background-color: #F6F6F6; 
}

footer {
font-family:"Proxima";
clear: both;
 color: black;
 font-size: 100%;
 margin-top: 0%;
 margin-right: 5%;
 margin-left: 5%;
 text-align: center;
 padding-top: 2%;

}

If you want to recieve an email when someone has entered their information you could do like this:如果您想在有人输入信息时收到电子邮件,您可以这样做:

PHP: PHP:

<?php
$to = "youremail@youremail.com"; 
$name = $_POST['name'];
$email = $_POST['email'];
$text = $_POST['text'];

$headers = "From: " .  $email;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";


if(isset($_POST['submit'])){
    $subject  = "New email from your website";

    $message   = "Name: " . $name;
    $message  .= "Email: " . $email;
    $message  .= "Message: " . $text;

    mail($to,$subject,$message,$headers);   
    echo "Your mail has been sent.";
}


?>

HTML: HTML:

<form class="form" method="POST" action="">
<p class="name">
  <input type="text" name="name" id="name" />
  <label for="name">Name</label>
</p>
<p class="email">
  <input type="text" name="email" id="email" />
  <label for="email">E-mail</label>
</p>

<p class="text">
  <textarea name="text" placeholder="Your message here"></textarea>
</p>
<p class="submit">
  <input type="submit" value="send" />
</p>
</form>
<form class="form" action="form.php" method="post" >

<p class="name">
  <input type="text" name="name" id="name" />
  <label for="name">Name</label>
</p>
<p class="email">
  <input type="text" name="email" id="email" />
  <label for="email">E-mail</label>
</p>

<p class="text">
  <textarea name="text" placeholder="Your message here"></textarea>
</p>
<p class="submit">
  <input type="submit" value="send" />
</p>
</form>

php php

<?php
$to = "info@matictoni.com"; 
$name = $_POST['name'];
$email = $_POST['email'];
$text = $_POST['text'];

$headers = "From: " .  $email;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";


if(isset($_POST['submit'])){
$subject  = "New email from your website";

$message   = "Name: " . $name;
$message  .= "Email: " . $email;
$message  .= "Message: " . $text;

mail($to,$subject,$message,$headers);   
echo "Your mail has been sent.";
}


?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM