...

View Full Version : Help needed with php script on GoDaddy hosting account



Tangentina
08-28-2011, 02:06 PM
Hi everyone,
I have two email forms I designed with CSS and HTML which I want to use on two of the domains I have on my shared hosting account with GoDaddy.

I have tried a few sample scripts with the accompanying html files but with this shared hosting the form won’t work with the php file in the same directory as the html form. It has to work from the root directory.

Go Daddy cannot give me custom scripting advice for the obvious reasons but have informed me that some customers have managed to get their php files working for their different domains by looking at the script that GoDaddy supply in the root directory and working it out.

I am able to configure my html form to work with the basic php mailform scripts I can get free online but do not know php and wouldn’t have a clue how to customise it so that it works on that page from my root directory. I imagine that I may need two separate scripts for the two domains I want the forms to work on.

The php script that GoDaddy supply which apparently only works with the main domain (for which I do not need an email form) is as follows:




<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
$query_vars = $_GET;
} elseif ($request_method == "POST"){
$query_vars = $_POST;
}
reset($query_vars);
$t = date("U");

$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
fputs($fp,"$val\n");
fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp);
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}



?>



Can anyone help me with this please?

tracknut
08-28-2011, 04:35 PM
I would not use the script above that GoDaddy provides, it buffers your email outputs, potentially for a long time.

I've found nothing different using PHP at GoDaddy than anywhere else. You might post your original html and php files so we can see them. They certainly can be in the same directory.

Dave

Tangentina
08-28-2011, 05:09 PM
Hi tracknut and thanks for your reply. I haven't got any php files yet. I was going to find a script to use with the form. I downloaded 4 basic scripts complete with html files and placed them in the same directory but they didn't work.

When I called GoDaddy they told me that the php file would only work if it was placed in the root directory. The two sites I want to run the forms on are in different folders.

Not sure if I am allowed to post the url of my form. I couldn't see anything in the rules against it. So I'll try.

This is the form I designed for one of the sites (http://www.frankstatesboro.co.uk/contact/form.html) but when I went to Web Form Factory to try to generate php for the form it kept telling me I had no submit button, even when I changed the html as they recommended.

If I could get one of the basic scripts and forms working I am sure I could then configure the html to work with the script, but so far I have had no luck.

tracknut
08-28-2011, 07:18 PM
Here's a test... first correct a couple things in your form:


<form id="form" name="form" method="post" action="/webformmailer.php">


should be (because you say you want the php file in the same directory as the contact form):


<form id="form" name="form" method="post" action="webformmailer.php">


Also you've got typos on this line:


<button type="submit name="submit" value="submit"">click to send message now</button>


so make it:


<button type="submit" name="submit" value="submit">click to send message now</button>


Then here's a very short version of webformmailer.php:


<?php
$email = "user@example.com"; //who does this mail get sent from (must be in the same domain as this site)
$recipient = "admin@example.com"; //who does this mail get sent to?
$body = $_POST['comments']; //contents of the message
$subject = "Subject line"; //subject line
$headers = "From: ". $email . "\r\n";

if (!mail ($recipient, $subject, $body, $headers))
echo "Couldn't send mail";
?>


Try that and see if it works.
Dave

Tangentina
08-29-2011, 04:35 PM
Hi Dave, Thanks for your help. I have done what you say and it makes the submit button ugly. I had this problem before and will work out how to deal with that later.

But now when I click the submit button I get asked if I want to download webformmailer.php !
I did set the same email address for the sent from and sent to - not sure if this is ok or not.

Just changed it to send to a different email address and the same thing happens.
Nothing was sent to either email account.

That has stopped happening now
Have mail sent from bookings@frankstatesboro.co.uk
and mail sent to lois@safemotoring.co.uk
and I get the error message from the php file = Couldn't send mail

Changed it back so that the mail is sent from and to bookings@frankstatesboro.co.uk but still getting the error message

tracknut
08-29-2011, 05:11 PM
I'm not following you with your various edits...

Is it still asking you to download webformmailer.php?

Is it sending and are you receiving mails?

Dave

Tangentina
08-29-2011, 05:43 PM
It is no longer asking me to download the file
But I am getting the error message from the script: Couldn't send mail
And no mail is being sent


Also I downloaded an html form and script and put them in the folder:
http://www.frankstatesboro.co.uk/contact/trial.html
This says that the email was sent - but it isn't
Are you certain that I am able to place the php script in a folder because support told me it would only ever work from the root

Tangentina
08-29-2011, 05:58 PM
Just so I can try it I have got the html right to redirect to the form mail script in the root?
The form is in frankstatesboro/contact
I changed
action="send_form_email.php"
to
action="../../send_form_email.php"
but it till isn't working

Tangentina
08-29-2011, 06:05 PM
I have now changed it to
action="http://www.allmywebsites.co.uk/send_form_email.php"
which is my root directory and now again it says that it was successful yet no email has been sent.

This is the first major problem I have found with GoDaddy

Tangentina
08-29-2011, 06:16 PM
I just also tried pointing the original form to the revised webformmailer script you sent me which I placed in the root folder and am still getting the error message.

To use either script provided by GoDaddy I have to put in the email address I want the results sent to, so I could only use the form for one domain.

It seems to me that they have somehow disabled the use of php scripts other than their own in the root directory which only allow for the feedback to go to one address.

Nightfire
08-29-2011, 07:56 PM
I thought I read quite a while ago that godaddy only allows mail() to work if the 'to' address is the same one as the domain. Is the 'to' the same domain?

Tangentina
08-29-2011, 10:37 PM
Hi Nightfire,
It isn't at the moment but I don't think it will work if it is the same domain that the form resides on. I think they only allow it for the main hosted domain.
That for me is allmywebsites.co.uk and it doesn't have a web site.
I suppose I could create an email address for it thought and try that.

Is there any other option?
javascript?
I prefer php

tracknut
08-29-2011, 10:56 PM
I'm a bit stumped, here's a couple thoughts, but I have no good ideas:
1. Is this a "regular" paid hosting from GoDaddy, or is it some free service?
2. I do get delays in receiving mails from mail(), sometimes up to an hour or so
3. Your "from" address does need to be an address at the hosted domain (can be a fake address, it just needs to be at the same domain the call is made from). The "to" address can be anywhere.
4. I've never seen the failure from the actual mail() call before, which is why I'm thinking maybe you don't have a full hosting plan and possibly they don't support mail() from non-paid accounts. But that's only a guess.

Dave

Tangentina
08-30-2011, 12:00 AM
Hi again Dave,
I have paid, unfortunately for five years!
It is a shared hosting account but I've always had shared hosting accounts and never had this problem with anyone else.

I found these pages that you might understand more thoroughly than I do:
Picobits (http://picobits.com/2007/12/how-to-create-a-contact-form-on-a-godaddy-hosting-account/)
Dynamicdrive (http://www.dynamicdrive.com/forums/showthread.php?t=25833)
and Godaddys own forum (http://community.godaddy.com/groups/web-hosting/forum/topic/problem-with-sending-email-using-php-mail-function/)

I am hoping I can get a result somehow so that I can use email forms on any of my domains that I have hosted with Godaddy but I am a little stuck at the moment.

tracknut
08-30-2011, 12:23 AM
The only thing I get out of those sites is that mail() can be flaky on their Windows hosting. Are you on Windows or Unix?

And are you sending "from" an address on the hosted domain?

Dave

Tangentina
08-30-2011, 01:12 AM
Linux/Shared Hosting
Yes sending from email on one of the hosted domains

Just called support again and this time was told that any cgi script of my own should work from the same folder as the form html file and that it has to be a scripting error.

This is very different to what I was told yesterday.

tracknut
08-30-2011, 01:30 AM
Could you post the php script you're using - hopefully the one I made, but updated with your emails and such?

Dave

PS: Yes, your hosting tech support people aren't web developers...

Tangentina
08-30-2011, 01:42 AM
The form is on this page. (http://www.frankstatesboro.co.uk/contact/form.html)

And the code you sent me is as follows:

<?php
$email = "bookings@frankstatesboro.co.uk"; //who does this mail get sent from (must be in the same domain as this site)
$recipient = "bookings@frankstatesboro.co.uk"; //who does this mail get sent to?
$body = $_POST['comments']; //contents of the message
$subject = "Subject line"; //subject line
$headers = "From: ". $email . "\r\n";

if (!mail ($recipient, $subject, $body, $headers))
echo "Couldn't send mail";
?>

I have downloaded another script and put it on this page (http://www.safemotoring.co.uk/testform/form.html) and when I send using this form I get the success message but no email is sent. I have explained this to the support people but am getting nowhere.

Tangentina
08-30-2011, 06:37 PM
I'm just off the phone from GoDaddy support and finally on my ninth call I have been informed that they have been blocking the mail() function for every site on my account.
They say that it is probably due to a low security script.

I have deleted all the scripts and will attempt to reinstall their own php mail scripts and set that up and then write to them to ask if they can remove the block.
Thanks so much for your help.
I am sure I'll be back soon,
Lois.

pm99
10-04-2012, 06:42 PM
Hey Guys/Gals,
I'm using webformmailer.php on godaddy and it all works well. It send my form data to the email address I specify, however, the only set back is the 'thank you' page that I'd like to redirect the user to upon successful completion of the form.

Currently when I specify a redirect url such as...

<input type="hidden" name="redirect" value="http://mywebsite.com/thankyou.html" />

I get a 404.

But when I DON'T specify the redirect I am redirected to the ROOT of my web site http://mywebsite.com

My environment:
building a jqmobi mobile app
testing on an iphone4

as a side note, I've tried adding the following to webformmailer.php
$redirect = "http://mywebsite.com/thankyou.html";
but this does not appear to work or I'm doing it wrong.

Any thoughts anyone?
Appreciate the help.

PM99



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum