cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up a PHP email form

sgkconsulting
Newbie
Posts: 6
Registered: ‎15-01-2008

Setting up a PHP email form

Hi All
I'm struggling to set up a PHP script to email details that my website visitors enter in a form. Should be simple right???
The web form is on a HTML page that I've published to ftp.plus.net and the script is a PHP file I've published to cshell.plus.net. But how do I link the two? The way I've done it in the past is to set the Action attribute for the HTML form to point to the CSS script but although they are in the same directory on my PC when I publish them to separate locations, I think they lose the link?
Generally, it seems a pain in the %^&* to have to publish one file to a separate location. Is there a neat way to do this, other than manually publishing the script to it's own location?
If it makes any difference I'm using MS Expression Web 4.0. I'd rather not use the sample form that Plusnet provide as I want to have a cleaner configuration by keeping the PHP in a separate file.
Am I missing a simple way to achieve this?
Thanks
Steve
14 REPLIES 14
jelv
Seasoned Hero
Posts: 26,785
Thanks: 971
Fixes: 10
Registered: ‎10-04-2007

Re: Setting up a PHP email form

The link to the script has to have the full URL (i.e. http://ccgi... )
Alternatively you can have your whole website moved across with www pointing to the ccgi server.
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
nehoc
Dabbler
Posts: 13
Registered: ‎15-12-2010

Re: Setting up a PHP email form

I think I have exactly the same problem ...
I have a support thread going back to October with Plus asking for help to which they kept promising a reply and apologising for not providing, until I got this just now:
'Thank you for your query. although we provide you access to our ccgi servers and can confirm that the mail() command is supported on our serves. we are unable to provide with scripting support and I would suggest that you seek further assistance via our community forum at the following link. http://community.plus.net/forum/index.php/'
So, here I am. If you look at http://www.resurgam.info/MissingPortraits/Contact/index.php you will see a php script working just fine and it has been working on another server as well. My domain, http://www.MissingPortraits.info points at http://www.nehoc.plus.com and that would be pointed at the ccgi server if php worked there for me, but it is temporarily linked to the resurgam address as the script won't run on the ccgi server - see http://ccgi.nehoc.plus.com/Contact/index.php. Tho the page is slightly changed on resurgam since I moved it there the script is identical and it worked on resurgam and another site before I changed the design.
At one point Plus said 'The script doesn't load as it requires specific permissions to do this. Your client may refer to this as CHMODing. You need to CHMOD the files to 755', but doing this to each file made no difference: My web design software does this anyway at directory level and that's goo enough for the other hosts.
The best suggestion I have is that the ccgi server is not set correctly - a most experienced web site creator in the US says of my problem that the 'Action uses the PHP mail() command, which on a normal (which is to say Unix or Linux) Web server wraps around the Unix daemon (friendly demon)  sendmail or the local equivalent.
On a Windows Web server (a contradiction in terms -- make no mistake) you will rely on your system manager having properly configured PHP when it was installed such that it wrapped around the local or remote SMTP server instead.
If this was properly done, then the PHP mail() function abstracts this whole end of things away from you -- there is no functional difference between  sending a message through mail() on either platform.
You will most likely find yourself unable to send mail through PHP using the mail() command on this server under any circumstances.'
Is he right that basically I have no hope with Plus and will have to pay to have my domain redirected to a competent host?
Cheers, Colin
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: Setting up a PHP email form

I've had a quick look at that file on one of our ccgi servers, and the permissions are not correct, they are 0640, so the file is not executable. It seems that although your web design software may set this permission locally it is not preserving these permissions when it uploads it to us.
Due to the needs of our ccgi platform (e.g. many, many users which need their scripts to be properly separate from other users) we use suexec, which requires php files to be executable. Other hosts might not, which would explain why it may work with other providers but not on our platform.
The PHP mail() command does work and is used successfully by many of our customers on this platform.
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: Setting up a PHP email form

Quote from: nehoc
Is he right that basically I have no hope with Plus and will have to pay to have my domain redirected to a competent host?

No he's not right. The cgi servers run Apache on a Linux operating system using the suEXEC security model. Have you had a look at the CGI Upgrade FAQ stickied at the top of this forum?
David
sgkconsulting
Newbie
Posts: 6
Registered: ‎15-01-2008

Re: Setting up a PHP email form

AS the person who kicked off this thread, I should add that since I've corrected the path to my PHP script (thanks to jelv) I've successfully created emails.
But I do have a problem with my very simple script:
<?php
$to = 'email hidden for this post';
$subject = 'Mailing List Subscription';
$header = $_POST['Email'];
$message = '$Name $Email $Company';
mail ($to, $subject, $message, "From: <$header>");
?>
The variables $Name, $Email and $Company are the field names on the HTML form but when I check the email, the message just lists the variable names not their values.
I'm sure I'm missing something simple but I've tried changing field names and syntax without success.
Can a PHP expert point me in the right direction please
Thanks
Steve
nehoc
Dabbler
Posts: 13
Registered: ‎15-12-2010

Re: Setting up a PHP email form

Thanks Ben for the reply:
1  I have only just caught up with it and will look in the morning. Even then I don't think it will mean anything to me [I have used computers for 25 years, but my background is graphics, not servers], so can anyone suggest what tools I need to set this form correctly  and every time I upload a new version of the site from Freeway will I then have to go in and change some parameters on that page?
2  I can't begin to tell you how i feel having been asking Plusnet for the answer to this conundrum for perhaps six week [incredibly stressful as I was therefore very late launching the site which was meant to be ready for a seminar] to be told yesterday by Plusnet support that they did not know the answer and today that they do [even if I as an EU have no idea what it means!].
I guess that's life,
Colin
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: Setting up a PHP email form

Quote from: sgkconsulting
$message = '$Name $Email $Company';
The variables $Name, $Email and $Company are the field names on the HTML form but when I check the email, the message just lists the variable names not their values.

Variable names in string fields enclosed by single quotes ('...') are *not* interpolated (substituted) whereas those inside double quotes ("...") are. You need to make that line
$message = "$Name $Email $Company";
But have you set the variable values from the $_POST global (as you did with $header)?
Assuming the form names are identical it will work without this at the moment because register_globals is on, but will fail when that is turned off.
David Smiley
David
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: Setting up a PHP email form

Hi Colin,
Quote from: nehoc
... so can anyone suggest what tools I need to set this form correctly  and every time I upload a new version of the site from Freeway will I then have to go in and change some parameters on that page?

I'd recommend using an FTP client like FileZilla. Once you have logged in to your site, right click on the file you want to change the permissions of and chose 'File Permissions...'. In the dialogue that comes up tick the 'executable' boxes and hit 'OK'
Quote from: nehoc
2  I can't begin to tell you how i feel having been asking Plusnet for the answer to this conundrum for perhaps six week [incredibly stressful as I was therefore very late launching the site which was meant to be ready for a seminar] to be told yesterday by Plusnet support that they did not know the answer and today that they do [even if I as an EU have no idea what it means!].

It's a bit of a tricky one, and I'm sorry that it took so long for you to get an answer, but we don't officially support CCGI, so our support staff are only given very limited training on it. As you may have noticed by my sig I'm not a member of our support staff, I'm in our engineering department and actually designed a lot of the current CCGI platform so have more knowledge of it. I do check these forums from time to time and try to help people out but it's not the main focus of my job so I don't often get time to do it. Having said that most of the other customers who post in this forum have a good working knowledge of the platform and are generally very good at helping fellow customers with their queries, so you shouldn't need me in here much Wink
Ben
sgkconsulting
Newbie
Posts: 6
Registered: ‎15-01-2008

Re: Setting up a PHP email form

Thanks Spraxyt, that works a treat
Steve
nehoc
Dabbler
Posts: 13
Registered: ‎15-12-2010

Re: Setting up a PHP email form

Thanks Ben, I now realise I am in a delicate area!
Freeway Pro uploads my site to other servers OK, and as I think I said it sets the Contact *folder* for execute. However, Freeway will not upload to ccgi.plus, but it will to ftp.plus, so I have had to use an FTP client [I use OneButton FTP from my Macs] and as instructed, I seem to remember by Bob Pullen, I used BatCHMOD to change the individual files to 755 tho as I say on other severs having the folder/directory set to execute is all that is needed.
Are you now saying that the process is that I FTP the whole site to CCGI and then using BatCHMOD I set those index.php and index-go in Contact to Execute? But, hang on, I thought that was what I had already done a week or two back ...
So, I have just gone in again, copied back the three PHP files to my Desktop, used BatCHMOD to make them executable by everyone and deleted those files on ccgi and replaced them with the ones with Everyone set to Execute. I then cleared my browser cache and went to the contact page again and it still does not work ...
As you can see, this is way above my pay grade!
Cheers, Colin
7up
Community Veteran
Posts: 15,828
Thanks: 1,583
Fixes: 17
Registered: ‎01-08-2007

Re: Setting up a PHP email form

Quote from: nehoc
I have just gone in again, copied back the three PHP files to my Desktop, used BatCHMOD to make them executable by everyone and deleted those files on ccgi and replaced them with the ones with Everyone set to Execute. I then cleared my browser cache and went to the contact page again and it still does not work ...

You can't download the files to your desktop and set the permissions. You change the permissions of the files ON THE SERVER. Changing them locally on your computer won't do anything except change them on your computer. When you then upload them those permissions aren't preserved (unless of course your using some ultra cool bit of software which does that automatically and I've never found one yet).
FTP the files up and once they're uploaded right click on them and look for a setting called CHMOD or Permissions. It varies from one FTP client to another though so you may need to consult the docs.
I need a new signature... i'm bored of the old one!
nehoc
Dabbler
Posts: 13
Registered: ‎15-12-2010

Re: Setting up a PHP email form

Thanks okrzynska - I've only just seen your post.
Never having built a site before I am at a bit of a loss. I can either use an ftp client to upload or I can use the web design app [Freeway, I am a Mac user]. The latter is easier as it is a single click when all is ready and the php page [under contact at www. MissingPortraits.info] works on two other servers I have tried, but not at Plusnet.
As I understand it if I do what you say, every time I upload a revision I'd have to use the ftp client and not upload the contact page [which is not likely to change] or I'd have to change the permissions on the server every revision. To reiterate, Freeway automatically sets the php files to execute and the other servers I have tried do NOT reset them, but Plusnet's ccgi server does ...
Cheers, Colin
7up
Community Veteran
Posts: 15,828
Thanks: 1,583
Fixes: 17
Registered: ‎01-08-2007

Re: Setting up a PHP email form

Sorry for the delay replying, I forgot about this topic.
Yes if PN's server is resetting your file permissions every time you modify it you will need to connect via FTP and reset the permissions manually. It's a pain I know and I've used a server or two thats quirky in this way myself over the years.
One thing you could do is write a php script which automatically scans the directories and updates the permissions for all .php files. That way you wouldn't need to manually do it via ftp you could just make a http call.
I need a new signature... i'm bored of the old one!
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: Setting up a PHP email form

The cgi script included in this post will set suitable permissions for you. However PN's ccgi server retains existing permissions when an existing file is replaced/overwritten. For new files permissions are set based on directory permissions and the umask as is normal on Linux systems.
David