只有获得消息'提交联系表格时的部分

时间:2017-09-05 05:26:00

标签: php html contact-form

使用简单的联系表格。我把它托管在我的服务器上。在我按“发送”后填写所有信息后按钮我只收到我在“消息”中输入的内容。部分到我的电子邮件。我该怎么做才能获得其他字段(姓名,电子邮件,电话)。似乎无法确定问题。



public void Observation (String observed) {
    boolean found = false;
    for (Bird x : getBirds()) { // this has to be a method
        if (x.getName() != null && x.getLatin() != null && x.getName().contains(observed) || x.getLatin().contains(observed)) {
            System.out.println("Done");
            System.out.println("");
            x.increaseCount();
            found = true;      
        } 
    }
    if (!found) {
            System.out.println("Not a bird");
    }
}

/*----------------- START OF FORM -----------------     */    
    
    @import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,600);

* {
	margin:0;
	padding:0;
	box-sizing:border-box;
	-webkit-box-sizing:border-box;
	-moz-box-sizing:border-box;
	-webkit-font-smoothing:antialiased;
	-moz-font-smoothing:antialiased;
	-o-font-smoothing:antialiased;
	font-smoothing:antialiased;
	text-rendering:optimizeLegibility;
}

body {
	font-family:"Open Sans", Helvetica, Arial, sans-serif;
	font-weight:300;
	font-size: 12px;
	line-height:30px;
	color:#777;
/*	background:#0CF;*/
}

.error {
    color: red;
}

.success {
    color: #ff9966;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
}

.container5 {
	max-width:500px;
	width:100%;
	margin:0 auto;
	position:relative;
    float: left;
}

#contact input[type="text"], #contact input[type="email"], #contact input[type="tel"], #contact input[type="url"], #contact textarea, #contact button[type="submit"] { font:400 12px/16px "Open Sans", Helvetica, Arial, sans-serif; }

#contact {
	background:#F9F9F9;
	padding:25px;
	margin: 0;
}

#contact h3 {
	color: #F96;
	display: block;
	font-size: 30px;
	font-weight: 400;
}

#contact h4 {
	margin:5px 0 15px;
	display:block;
	font-size:13px;
}

fieldset {
	border: medium none !important;
	margin: 0 0 10px;
	min-width: 100%;
	padding: 0;
	width: 100%;
}

#contact input[type="text"], #contact input[type="email"], #contact input[type="tel"], #contact input[type="url"], #contact textarea {
	width:100%;
	border:1px solid #CCC;
	background:#FFF;
	margin:0 0 5px;
	padding:10px;
}

#contact input[type="text"]:hover, #contact input[type="email"]:hover, #contact input[type="tel"]:hover, #contact input[type="url"]:hover, #contact textarea:hover {
	-webkit-transition:border-color 0.3s ease-in-out;
	-moz-transition:border-color 0.3s ease-in-out;
	transition:border-color 0.3s ease-in-out;
	border:1px solid #AAA;
}

#contact textarea {
	height:100px;
	max-width:100%;
  resize:none;
}

#contact button[type="submit"] {
	cursor:pointer;
	width:100%;
	border:none;
	background:#0CF;
	color:#FFF;
	margin:0 0 5px;
	padding:10px;
	font-size:15px;
}

#contact button[type="submit"]:hover {
	background:#09C;
	-webkit-transition:background 0.3s ease-in-out;
	-moz-transition:background 0.3s ease-in-out;
	transition:background-color 0.3s ease-in-out;
}

#contact button[type="submit"]:active { box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.5); }

#contact input:focus, #contact textarea:focus {
	outline:0;
	border:1px solid #999;
}
::-webkit-input-placeholder {
 color:#888;
}
:-moz-placeholder {
 color:#888;
}
::-moz-placeholder {
 color:#888;
}
:-ms-input-placeholder {
 color:#888;
}

#sendButton{
    background-color: rgba(204, 204, 204, 0.52);
    color: black;
    width: 60px;
    font-weight: bold;
}

    
/*----------------- END OF FORM -----------------     */  




PHP:

<link rel="stylesheet" href="form.css" type="text/css">
<div class="container5">  
<form id="contact" action="form_process.php" method="POST">    
    <h3>Contact</h3>
    <h4>Contact us today, and get reply with in 24 hours!</h4>
    <fieldset>
      <input placeholder="Your name" type="text" name="name"  tabindex="1" autofocus>
      <span class="error"><?= $name_error ?></span>
    </fieldset>
    <fieldset>
      <input placeholder="Your Email Address" type="text" name="email"  tabindex="2">
      <span class="error"><?= $email_error ?></span>
    </fieldset>
    <fieldset>
      <input placeholder="Your Phone Number" type="text" name="phone"  tabindex="3">
      <span class="error"><?= $phone_error ?></span>
    </fieldset>
    <fieldset>
      <textarea  name="message" tabindex="5">
      </textarea>
    </fieldset>
    <fieldset>
       <input  type="submit" value="Send">
    </fieldset>
    <div class="success"><?= $success ?></div>
  </form>
</div>

1 个答案:

答案 0 :(得分:0)

$ message_body

替换 $ message

示例

if (mail($to, $subject, $message_body)){
          $success = "Message sent, thank you for contacting us!";
          $name = $email = $phone = $message = '';
      }