Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > WebsitePainter
Creating a PHP Contact Form

weewasta
Registered User
Quote
2012-04-12 22:18:15

Hi

Over the last few days I have been attempting to create (and publish) a contact form following the instructions in your on-line manual. I created a simple site with 2 pages (the second page contains the form). Then loaded it to the web. When the browser attempted to open the page containing the form (called 'contact.php') it returned the message of "Parse error: syntax error, unexpected T_VARIABLE in /freeola/users/2/1/sr0876612/htdocs/contact.php on line 32".

Since receiving this message I have:-

1 - Gone through the manual instructions again to make sure I had not left anything out / made an error input etc
2 - Checked with my web host company that they accept PHP coded sites - they do (see PS below)
3 - Reloaded the site to the web host servers
4 - Put the code created in contact.php through 2 code testing packages - no errors detected
5 - Read through this Forum (for similar issues)
5 - Run out of ideas.....!!!

Do you have any idea what I have done wrong ?

Can you give me the URL of a site that has successfully created a Contact Form using you instructions so I can go and have a look at the source code to see if I can sort this out?

PS - My hosting company does make the following comments about sites with PHP code...... http://freeola.com/support/php-scripting-essentials.html ..... could the problem be because of PHP File & Folder Premissions. I use their 'standard hosting' and used CyberDuck as my FTP.

I use WebSitePainter for a couple of site developments. Both developments have been very successful. But developing a contact form has beaten me - any help will be appreciated. Many thanks




niko
Moderator
Quote
2012-04-13 07:48:34

Hi,

the error you get means that the code you typed into the PHP element has some syntax error in it. Did you modify the code maybe? What does it look like exactly? Does it look like this?

$text = "";
foreach($_POST as $name => $value)
{
$text .= "$name : $value\n";
}

if ($text != "")
{
echo 'Thanks for contacting us.';
mail("youremail@example.com", "Contact form request", $text);
}



weewasta
Registered User
Quote
2012-04-13 11:03:05

Hi

This is the code I have in the PHP Code box....

$text = "";
foreach($_POST as $name => $value)
{
  $text .= "$name : $value\n";
}

if ($text != "")
{
  echo 'Thanks for contacting us.';
  mail("andrew@andrewandcat.co.uk", "Contact form request", $text);
}

I placed the code in the box via cut & paste - I did not write the code in. The only typing I did was to replace the example email address with a real one.

I am on WebsitePainter 2.0.1

Thanks


niko
Moderator
Quote
2012-04-13 12:07:46

Strange, looks ok for me. Maybe you could send me your .wspd file and I'll have a closer look at it? Maybe mail adress written on the page under Support -> Contact.


weewasta
Registered User
Quote
2012-04-13 13:07:59

Just sent the file to you via office@ambiera.com


weewasta
Registered User
Quote
2012-04-13 14:19:56

To anyone with the same problem I had. This is the solution Niko emailed me with.....

I took a look at it and was able to fix it. Simply remove the spaces at the
beginning of each lines, somehow, those are evil for some reasons. The code
should then look like this:

$text = "";
foreach($_POST as $name => $value)
{
$text .= "$name : $value\n";
}

if ($text != "")
{
echo 'Thanks for contacting us.';
mail("andrew@andrewandcat.co.uk", "Contact form request", $text);
}

I'm not entirely sure what happened there and why the spaces/tabs in your
code are not liked, but removing them fixes it. Must have been some way they
have been copied, maybe.


I then tested Niko's solution and it worked. Perhaps the core of the problem was the way my computer copies and pastes - I used CMD + C to copy and CMD + V to paste, I work on an iMac.


Alicia
Guest
Quote
2013-06-15 04:51:11

I would recommend Code Shacks contact form, its really easy to implement and the code is easy to understand

http://codetutorial.caroshaw.com/jquery_image_slider.php


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact