-3
我是HTML和PHP編程的新手。 當我從表單提交數據$ POST不是從表單獲取值,只是空值正在郵寄.spent相當多的時間,但無法想出它。
以下是代碼的一部分下面我的HTML表單
<form id="main-contact-form" class="contact-form" name="contact-form" method="POST" action="sendemail.php">
<div class="form-group">
<input type="text" name="namefirst" class="form-control" required="required" placeholder="Name">
</div>
<div class="form-group">
<input type="email" name="emailfirst" class="form-control" placeholder="Email ID">
</div>
<div class="form-group">
<input type="tel" name="tel" class="form-control" placeholder="Mobile No">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary pull-right">Send</button>
</div>
</form>
的是我的PHP代碼
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for registering wth us.We will keep updating you.'
);
{
$name = $_POST["namefirst"];
$email = @trim(stripslashes($_POST["emailfirst"]));
$email_from = $email;
$email_to = '****';//replace with your email
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" ;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
}
?>
我已經嘗試了所有可能的解決方案,但它只是不working.Please讓我知道什麼是錯。
看起來你的代碼有語法錯誤。請注意,如果沒有if語句或什麼的話,{{'應該做什麼。 – Maximus2012
請發佈您的實際代碼。這不可能正確運行。 – TheValyreanGroup
抑制錯誤'@'實際上不會幫助您排除它。 – Qirel