Contact Form

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sun Sep 08, 2013 2:00 pm

Contact Form

Postby allentown » Sun Sep 08, 2013 2:20 pm

Hi experts,
I have tried to fix this issue, but some how it always throws me error. Definitely I must be wrong somewhere. But I couldn't figure it out. Request your kind guidance.

Following is my html code part for form:

Code: Select all

<section id="content">
        <div class="bg-2">
           <div class="main">
               <div class="wrapper">
                   <article class="col-1">
                       <strong class="title-3">Contact Form</strong>
                       <form id="contact-form" method="post" enctype="multipart/form-data">                   
                                <div class="wrapper">
                                    <label><span class="text-form">Your Name:</span><input name="cf_name" type="text" /></label>
                                    <label><span class="text-form">Your E-mail:</span><input name="cf_email" type="text" /></label>
                           <label><span class="text-form">Your Phone:</span><input name="cf_phone" type="text" /></label>                           
                                    <div class="wrapper"><div class="text-form">Your Message:</div><textarea name="cf_message"></textarea></div>
                                    <div class="buttons">
                                        <!--<a class="button" href="#" onClick="document.getElementById('contact-form').reset()">Clear</a>-->
                                        <!--<a class="button" href="#" onClick="document.getElementById('contact-form').submit()">Send</a>-->
                              <a class="button" href="javascript:" onClick="document.getElementById('contact-form').reset()">Clear</a>
                                        <a class="button" href="javascript:" onClick="document.getElementById('contact-form').submit()">Send</a>
                    <article class="col-2">
                       <strong class="title-3">Our Contacts</strong>
                        <dl class="p3">
                            <dt class="prev-indent-bot">Consultancy Services</dt>
                            <!--<dd><span>Telephone:</span>  +1 959 603 6035</dd>-->
                            <dd><span>E-mail:</span><a href="#"></a></dd>
                        <strong class="title-3">Miscellaneous Info</strong>

My PHP code is as below:

Code: Select all

$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_phone = $_POST['cf_phone'];
$field_message = $_POST['cf_message'];

$mail_to = '';
$subject = 'Message from a site visitor '.$field_name;

$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'E-mail: '.$field_phone."\n";
$body_message .= 'Message: '.$field_message;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
   <script language="javascript" type="text/javascript">
      alert('Thank you for the message. We will contact you shortly.');
      window.location = 'contact.html';
else { ?>
   <script language="javascript" type="text/javascript">
      alert('Message failed. Please, send an email to');
      window.location = 'contact.html';

I'm getting following error after clicking on "Send" button on the website:

405 - HTTP verb used to access this page is not allowed.

The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.

Request your kind attention and advise.

Thank you.
error.png (6.58 KiB) Viewed 890 times

New php-forum User
New php-forum User
Posts: 5
Joined: Fri Jul 19, 2013 11:07 am

Re: Contact Form

Postby cappy2354 » Wed Sep 11, 2013 9:49 am

From what I read about that error, it has something to do with the method="post" in your form on the HTML page. If you have not fixed it yet try changing the HTML page to a PHP page and in the form use action="whatever your mail page is called". It looks to me that when you click "SEND" there is no action in the form so it is calling "POST" and that may be what is throwing the error.

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 5 guests