PHP Script for Contact Form not working in CMSMS

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
fr0z3ng33k
Forum Members
Forum Members
Posts: 59
Joined: Thu Mar 03, 2011 4:47 pm

PHP Script for Contact Form not working in CMSMS

Post by fr0z3ng33k »

Had a site hosted by GoDaddy and this script worked along with the html version of the site. Since I've transferred it over to CMSMS (1.10.3) it no longer works. Am I missing something in my code? Server is running PHP5.3 - Thanks for the help and I apologize for my lack of knowledge.

html site:

Code: Select all

<section id="content">
            <article>
            	<h2>Contact <span>Form</span></h2>
              <form id="contacts-form" action="contact.php" method="post">
                <fieldset>
                  <div class="field">
                    <label>Name:</label>
                    <input type="text" value="" name="Name" />
                  </div>
                  <div class="field">
                    <label>E-mail:</label>
                    <input type="text" value="" name="E-mail" />
                  </div>
                  <div class="field">
                    <label>Phone:</label>
                    <input type="text" value="" name="Phone" />
                  </div>
                  <div class="field">
                    <label>Company:</label>
                    <input type="text" value="" name="Company" />
                  </div>
                  <div class="field">
                    <label>Message:</label>
                    <textarea></textarea>
                  </div>
                  <div><a href="thankyou.html" onclick="document.getElementById('contacts-form').submit()">Send Your Message!</a></div>
                </fieldset>
              </form>
            </article> 
          </section>
        </div>
      </div>
    </div>
  </div>
PHP Script:

Code: Select all

<?php

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$company = $_POST['company'];
$your_message = $_POST['message'];

$headers .= ‘Content-type: text/html; charset=iso-8859-1′;

$content = “<__html><head><title>Contact letter</title></head></__body><br>”;
$content .= “Name: <b>” . $name . “</b><br>”;
$content .= “Email: <b>” . $email . “</b><br>”;
$content .= “Phone: <b>” . $phone . “</b><br>”;
$content .= “Company: <b>” . $company . “</b><br><hr><br>”;
$content .= $your_message;
$content .= “<br><__body></__html>”;

$mail_to = 'info@mycompany.com';
$subject = 'Message from a site visitor '.$field_name;

mail($recipient,$subject,$content,$headers);
?>
<__html>
</__body bgcolor=”#282E2C”>
<div align=”center” style=”margin-top:60px;color:#FFFFFF;font-size:11px;font-family:Tahoma;font-weight:bold”>
Your message was sent. Thank you.
</div>
<__body>
</__html>
<__script__>resizeTo(300, 300)</__script>
scelle
Forum Members
Forum Members
Posts: 81
Joined: Sun Apr 24, 2011 8:14 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by scelle »

I don't know why is this script not working. I just wonder why you don't use the Form Builder module for creating forms? It's a core module (which means a great support and certain maintenance) that is widely used on CMS MS sites. And it's way, way, way simpler than this.
fr0z3ng33k
Forum Members
Forum Members
Posts: 59
Joined: Thu Mar 03, 2011 4:47 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by fr0z3ng33k »

I'd agree but it's what the boss wants so the boss gets it. Thanks for looking at it though!
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by Wishbone »

What happens when you submit the form?
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by Jos »

fr0z3ng33k wrote:I'd agree but it's what the boss wants so the boss gets it. Thanks for looking at it though!
Does the boss wants you to use this "script" or does the boss wants a contact form on the site that works properly.
If it's the first, I think he is not that good a boss :P
fr0z3ng33k
Forum Members
Forum Members
Posts: 59
Joined: Thu Mar 03, 2011 4:47 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by fr0z3ng33k »

Wishbone wrote:What happens when you submit the form?
It takes me to the ThankYou.html page but I never receive it in my inbox.
Jos wrote:
fr0z3ng33k wrote:I'd agree but it's what the boss wants so the boss gets it. Thanks for looking at it though!
Does the boss wants you to use this "script" or does the boss wants a contact form on the site that works properly.
If it's the first, I think he is not that good a boss :P
The boss wants me to use his script. Mainly because for this site he is using CMSMS but his other sites aren't. So he wants the same working script on everything.
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by Jos »

Code: Select all

$mail_to = 'info@mycompany.com';
$subject = 'Message from a site visitor '.$field_name;

mail($recipient,$subject,$content,$headers);
$field_name is not set anywhere
$recipient is not set anywhere
fr0z3ng33k
Forum Members
Forum Members
Posts: 59
Joined: Thu Mar 03, 2011 4:47 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by fr0z3ng33k »

Jos wrote:

Code: Select all

$mail_to = 'info@mycompany.com';
$subject = 'Message from a site visitor '.$field_name;

mail($recipient,$subject,$content,$headers);
$field_name is not set anywhere
$recipient is not set anywhere

How does this look and do I need to define name, email, etc (put it in the code for now but I can remove it).

Code: Select all

<?php

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$company = $_POST['company'];
$your_message = $_POST['message'];

$headers .= ‘Content-type: text/html; charset=iso-8859-1′;

$content = “<__html><head><title>Contact letter</title></head></__body><br>”;
$content .= “Name: <b>” . $name . “</b><br>”;
$content .= “Email: <b>” . $email . “</b><br>”;
$content .= “Phone: <b>” . $phone . “</b><br>”;
$content .= “Company: <b>” . $company . “</b><br><hr><br>”;
$content .= $your_message;
$content .= “<br><__body></__html>”;

$mail_to = 'info@mycompany.com';
$subject = 'Message from a site visitor ';

mail($name,$phone,$email,$company,$your_message,$subject,$content,$headers);
?>
<__html>
</__body bgcolor=”#282E2C”>
<div align=”center” style=”margin-top:60px;color:#FFFFFF;font-size:11px;font-family:Tahoma;font-weight:bold”>
Your message was sent. Thank you.
</div>
<__body>
</__html>
<__script__>resizeTo(300, 300)</__script>
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by Jos »

This might help: http://nl2.php.net/manual/en/function.mail.php

The real advise is still: use FormBuilder and you'll have your form running in minutes.
fr0z3ng33k
Forum Members
Forum Members
Posts: 59
Joined: Thu Mar 03, 2011 4:47 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by fr0z3ng33k »

Jos wrote: The real advise is still: use FormBuilder and you'll have your form running in minutes.
If I use that will it work on sites not running CMSMS? Boss wants consistency.
scelle
Forum Members
Forum Members
Posts: 81
Joined: Sun Apr 24, 2011 8:14 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by scelle »

Sure it will! You can set field ids, names etc... And you can create a custom template for the sent message. Try it, it's a great module!

Even better, show it to your boss, he'll love you for making his life A LOT easier! ;)
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by Wishbone »

If some of your sites are not using CMSMS, there's not much consistency anyways. Use that script on non-CMSMS sites. Use what's best for CMSMS (FormBuilder) on CMSMS sites.
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by Jos »

fr0z3ng33k wrote:Boss wants consistency.
I guess boss only cares about the email that is generated. You can make that look exactly the same as your other sites
fr0z3ng33k
Forum Members
Forum Members
Posts: 59
Joined: Thu Mar 03, 2011 4:47 pm

Re: PHP Script for Contact Form not working in CMSMS

Post by fr0z3ng33k »

Jos wrote:
fr0z3ng33k wrote:Boss wants consistency.
I guess boss only cares about the email that is generated. You can make that look exactly the same as your other sites
good to hear thanks all!
Post Reply

Return to “The Lounge”