how do I use my websites theme or template for my PHP contact form?

They have: 166 posts

Joined: Mar 2006

I have a php contact form script, but its just a white page with the input fields on it, pretty boring..

All I want to do is use my websites template or theme of my site for the form as well. And I also want to put it in the text area if possible.

Anyone know how to do that please?

Thanks.

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

It depends on what script you are using for your contact form and what the rest of your site is using.

You will most-likely have to edit the files of your contact form to match the rest of your site.

They have: 166 posts

Joined: Mar 2006

I want to put this php form, into my contact page so it has my header, buttons exactly looking like my site does, but with the form in the text area.

My contact page is xhtml.

Can I link to this form somehow and make it show up in an xhtml or html page I choose? So I can have the form showup exactly where I want it in my page? So i dont have to theme it with css, because my pages are already using css?

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Your form should be in a PHP file, you can edit that file to contain the same tags (heading area, sidebars and what not) as the rest of the pages on the site.

Can I link to this form somehow and make it show up in an xhtml or html page I choose?

Hmmm, possibly, but it will have to be a file with the name ending: .php, it's possible that Apache has been setup on your server to also treat .html files as PHP, although this configuration is uncommon.

Try making a copy of your chosen xhtml/html page to test.php, then add the following code:

<?php
 
include formfile.php;
?>

You'll need to change formfile.php to the name of the file your form is in. Hope this makes sense. Smiling

a Padded Cell our articles site!

They have: 166 posts

Joined: Mar 2006

Thanks Jeeves

I tried it, but wehre do I put the code? header, or place I want the form to appear?

http://twtcouriers.only-the-truth.com/twtcontact.php

Got errors.

Warning: main(contactphp): failed to open stream: No such file or directory in D:\Inetpub\vhosts\only-the-truth.com\subdomains\twtcouriers\httpdocs\twtcontact.php on line 28

Warning: main(): Failed opening 'contactphp' for inclusion (include_path='.;./includes;./pear') in D:\Inetpub\vhosts\only-the-truth.com\subdomains\twtcouriers\httpdocs\twtcontact.php on line 28

I couldnt name it contact.php because I already have a file contact.php with the form in it. So I named it twtcontact.php instead. it says its not there, but it mustbe otherwise the page wouldnt have opened right?

I also changed the formfile.php to contact.php.

You know where im going wrong bud?

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Ooops, think I got this wrong. Try:

<?php
 
include "contact.php";
?>

That will work, but you only really need one file for a contact page. It would probably be better to just copy the styling, headings, sidebars etc. into your contact.php

I tried it, but wehre do I put the code? header, or place I want the form to appear?

Where you want the form to appear. It will literally pull the whole contents of contact.php into twtcontact.php.

I couldnt name it contact.php because I already have a file contact.php with the form in it. So I named it twtcontact.php instead. it says its not there, but it mustbe otherwise the page wouldnt have opened right?

It's saying contact.php doesn't exist, but it's really having problems because I forgot the inch marks around the contact.php Smiling

a Padded Cell our articles site!

They have: 166 posts

Joined: Mar 2006

Oh legend, it works Laughing out loud

Yeah, I dont know how to do the styling, I didnt do it, sitegrinder did it. Put it all in a common.css file, and I tried to link the contact.php to that file, but all it gave me was the background.

But ill leave it this way, works great Laughing out loud

Thanks Jeeves Laughing out loud..

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

My pleasure! Smiling

If it works and you're happy, fine. Also if some third party thingy created your form for you, it's probably better to just include it, then if you create a new form you just have to overwrite the existing file.

a Padded Cell our articles site!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.