Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Adam Smallman
Adam Smallman
4,182 Points

Godaddy Form setup help

Hello guys, I have been using godaddy for sometime now, with a simple form setup along with their gdform.php.

They have change their UI to cPanel. This is giving me a lot of issues with the contact form.

Normally I could just go onto my account then to the mailer tab, there I could type in the email and the contact form would work. (send the contact form action over too gdfrom.php)

But since cPanel I can not longer do this, and my form no longer works!

Here is the contact handler that I have been using

    $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");
    $fp = fopen("../data/gdform_$t","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"]."/");
    }


?>

This has been working great. But it will no longer work. I think, maybe that it does not know where to send the email? I am not the best PhP coder!

This is the VERY simple form

```<form name='form' method='post' action='http://www.dannymsmallman.com/contactscript.php'> <input type="hidden" name="subject" value="Form Submission" /> <input type="text" name="name" value="Name" /> <input class="email" type="text" name="email" value="Email" /> <textarea name="email" cols="40" rows="10">Your Message </textarea> <input type="submit" name="submit" value="submit"/> </form>

Thanks guys! Any help would be great here!

1 Answer

Lauren Clark
Lauren Clark
33,155 Points

They may have changed the name of the file which executes the contact form, but not updated it in any links. Have you tired starting from scratch with it?

The alternative is to just use your own contact form or put your site on to wordpress and use the Contact Form 7 plugin etc.

If you want a contact form that's relatively easy to set up - I have one here which works with Foundation 5 to validate the fields and includes a honeypot spam filter. If you're not using Foundation just change the classes to your own CSS styling and chip away at the fields you don't need. It's all commented out, just replace the GoDaddyForm.php or whatever with this.

lauren's github

Alternatively check out the PHP course with Randy and see how to build a contact form using PHPMailer :)

PHP Contact Form Lesson

Adam Smallman
Adam Smallman
4,182 Points

Thank you Lauren, after many phone calls to Godaddy the issue was never fixed. But I will work on it myself.

Although Godaddy is giving me nothing but problems!

Thanks again!

Lauren Clark
Lauren Clark
33,155 Points

Get shot of GoDaddy if you can! They're not a great hosting company.