Web Analytics Made Easy -
StatCounter Help needed with php script on GoDaddy hosting account - CodingForum


No announcement yet.

Help needed with php script on GoDaddy hosting account

  • Filter
  • Time
  • Show
Clear All
new posts

  • 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:

        $request_method = $_SERVER["REQUEST_METHOD"];
        if($request_method == "GET"){
          $query_vars = $_GET;
        } elseif ($request_method == "POST"){
          $query_vars = $_POST;
        $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,"<GDFORM_VARIABLE NAME=$key END>\n");
         if ($key == "redirect") { $landing_page = $val;}
        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?

  • #2
    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.



    • #3
      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.


      • #4
        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:
        $email = "[email protected]";	//who does this mail get sent from (must be in the same domain as this site)
        $recipient = "[email protected]"; 	//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.


        • #5
          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 [email protected]
          and mail sent to [email protected]
          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 [email protected] but still getting the error message
          Last edited by Tangentina; Aug 29, 2011, 11:12 AM.


          • #6
            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?



            • #7
              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:

              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; Aug 29, 2011, 11:46 AM.


              • #8
                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
                but it till isn't working


                • #9
                  I have now changed it to
                  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


                  • #10
                    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.


                    • #11
                      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?


                      • #12
                        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?
                        I prefer php


                        • #13
                          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.



                          • #14
                            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:
                            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.


                            • #15
                              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?