Sunday 15 February 2015

php - send mail to email id through contact form -



php - send mail to email id through contact form -

i have contact form on website user can send message website owner. contact form is

<form class="form" id="form1" action="send_form_email.php" method="post"> <p class="name"> <input name="name" type="text" class="validate[required,custom[onlyletter],length[0,100]] feedback-input" placeholder="name" id="name" /> </p> <p class="phone"> <input name="phone" type="text" class="validate[required,custom[email]] feedback-input" id="phone" placeholder="phone number" /> </p> <p class="email"> <input name="email" type="text" class="validate[required,custom[email]] feedback-input" id="email" placeholder="email" /> </p> <p class="businessname"> <input name="business_name" type="text" class="validate[required,custom[onlyletter],length[0,100]] feedback-input" placeholder="business name" id="name" /> </p> <p class="text"> <textarea name="comment" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="comment"></textarea> </p> <div class="submit"> <input type="submit" name="submit" value="submit!" id="button-blue"/> <div class="ease"></div> </div> </form>

the coding send_form_email.php is:

<?php $name = $_post['name']; $phone = $_post['phone']; $email = $_post['email']; $business_name = $_post['business_name']; $comment = $_post['comment']; $from = 'from: website.com'; //url of contact form or website $to = 'user@gmail.com'; //my email id $subject = 'customer inquiry'; $body = "from: $name\n phone: $phone\n e-mail: $email\n business name: $business_name\n message:\n $message"; $headers .= "mime-version: 1.0\r\n"; $headers .= "content-type: text/html\r\n"; $headers = 'from: from@example.com' . "\r\n" . 'reply-to: reply@example.com' . "\r\n" . 'x-mailer: php/' . phpversion(); mail($to, $subject, $message, $headers); header( "location: index.html" ); ?>

the problem is showing error on line 6 (i.e $comment = $_post['comment'];) saying parse error: syntax error, unexpected t_string in /nfs/c11/h01/mnt/193678/domains/website.com/html/admin/send_form_email.php on line 6

edit: 1

i have removed error due server problem.. error when mail service beingness sent admin, message in mail service blank, wish receive name, email, phoneno, business , comment in mail

change $body message

$message = "from: $name\n phone: $phone\n e-mail: $email\n business name: $business_name\n message:\n ";

php email

No comments:

Post a Comment