Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-28-2011, 01:06 PM   PM User | #1
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
Help needed with php script on GoDaddy hosting account

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:

Code:
<?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?
Tangentina is offline   Reply With Quote
Old 08-28-2011, 03:35 PM   PM User | #2
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 892
Thanks: 4
Thanked 206 Times in 205 Posts
tracknut is an unknown quantity at this point
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
tracknut is offline   Reply With Quote
Old 08-28-2011, 04:09 PM   PM User | #3
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
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 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.
Tangentina is offline   Reply With Quote
Old 08-28-2011, 06:18 PM   PM User | #4
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 892
Thanks: 4
Thanked 206 Times in 205 Posts
tracknut is an unknown quantity at this point
Here's a test... first correct a couple things in your form:
Code:
<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):
Code:
<form id="form" name="form" method="post" action="webformmailer.php">
Also you've got typos on this line:
Code:
<button type="submit name="submit" value="submit"">click to send message now</button>
so make it:
Code:
<button type="submit" name="submit" value="submit">click to send message now</button>
Then here's a very short version of webformmailer.php:
Code:
<?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
tracknut is offline   Reply With Quote
Old 08-29-2011, 03:35 PM   PM User | #5
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
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

Last edited by Tangentina; 08-29-2011 at 04:12 PM..
Tangentina is offline   Reply With Quote
Old 08-29-2011, 04:11 PM   PM User | #6
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 892
Thanks: 4
Thanked 206 Times in 205 Posts
tracknut is an unknown quantity at this point
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
tracknut is offline   Reply With Quote
Old 08-29-2011, 04:43 PM   PM User | #7
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
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

Last edited by Tangentina; 08-29-2011 at 04:46 PM..
Tangentina is offline   Reply With Quote
Old 08-29-2011, 04:58 PM   PM User | #8
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
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
Code:
action="send_form_email.php"
to
Code:
action="../../send_form_email.php"
but it till isn't working
Tangentina is offline   Reply With Quote
Old 08-29-2011, 05:05 PM   PM User | #9
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
I have now changed it to
Code:
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 is offline   Reply With Quote
Old 08-29-2011, 05:16 PM   PM User | #10
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
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.
Tangentina is offline   Reply With Quote
Old 08-29-2011, 06:56 PM   PM User | #11
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
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?
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 08-29-2011, 09:37 PM   PM User | #12
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
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
Tangentina is offline   Reply With Quote
Old 08-29-2011, 09:56 PM   PM User | #13
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 892
Thanks: 4
Thanked 206 Times in 205 Posts
tracknut is an unknown quantity at this point
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
tracknut is offline   Reply With Quote
Old 08-29-2011, 11:00 PM   PM User | #14
Tangentina
New Coder

 
Join Date: Aug 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Tangentina is an unknown quantity at this point
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
Dynamicdrive
and Godaddys own forum

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.
Tangentina is offline   Reply With Quote
Old 08-29-2011, 11:23 PM   PM User | #15
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 892
Thanks: 4
Thanked 206 Times in 205 Posts
tracknut is an unknown quantity at this point
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
tracknut is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:44 AM.


Advertisement
Log in to turn off these ads.