PHP stopped working on Godaddy Linux

Hi,

I have a simple contact form on Godaddy, which stopped working.

Seems Godaddy changed the version of PHP running on my Linux hosting account.

Don’t remember what the previous version was, but now it is v 5.2 or 5.3 (radio button lets me select).

When I submit form … I get the ‘$subject’ and ‘$to’ comes to my email, but everything else is blank.

Could someone please tell me how to make this work. I couldn’t find the answer just by Googling it.

Thanks

Here is the PHP … that used to work

[php]

<? // add a prefix in the subject line so that you know the email was sent by online form $subject = "MY Contact Form ". $subject; $to = "[email protected]"; $msg = "Name: $contact\n\n"; $msg .= "Sender: $sender\n\n"; $msg .= "Subject: $subject\n\n"; $msg .= "Telephone: $telephone\n\n"; $msg .= "Mobile: $mobile\n\n"; $msg .= "Company Site: $company\n\n"; $msg .= "Message: $message\n\n"; mail($to, $subject, $msg, "From: $sender"); ?>

[/php]

I can take a guess and assume register_globals was enabled on your old PHP version. To find out, have your host enable it on the new version and test the script. Tell them to set ‘register_globals = On’ in php.ini

I do not recommend using register_globals (it’s actually already deprecated and removed from newer PHP versions). However, if your script works, then we can help with updating the code.

If this is actually all the code, try this:

[php]

<?php // add a prefix in the subject line so that you know the email was sent by online form $subject = "MY Contact Form ". $subject; $to = "[email protected]"; $msg = "Name: $_POST['contact']\n\n"; $msg .= "Sender: $_POST['sender']\n\n"; $msg .= "Subject: $_POST['subject']\n\n"; $msg .= "Telephone: $_POST['telephone']\n\n"; $msg .= "Mobile: $_POST['mobile']\n\n"; $msg .= "Company Site: $_POST['company']\n\n"; $msg .= "Message: $_POST['message']\n\n"; mail($to, $subject, $msg, "From: $sender"); ?>

[/php]

That PHP didn’t work, but thank you for taking the time to respond!

GoDaddy has a generic PHP script that they include with hosting.

I tried it the other day, and it didn’t work.

After trying your code … I selected v PHP 5.3 in Godaddy, and it started working.

It seems GoDaddy wants people to use their script.

The generic GoDaddy code is below.

<?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,"\n"); fputs($fp,"$val\n"); fputs($fp,"\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"]."/"); } ?>

Thanks again for your help! I appreciate it!

try this:
[php]

Note the curly brackets in this version {}

$to = "[email protected]";
$msg = “Name: {$_POST[‘contact’]}\n\n”;
$msg .= “Sender: {$_POST[‘sender’]}\n\n”;
$msg .= “Subject: {$_POST[‘subject’]}\n\n”;
$msg .= “Telephone: {$_POST[‘telephone’]}\n\n”;
$msg .= “Mobile: {$_POST[‘mobile’]}\n\n”;
$msg .= “Company Site: {$_POST[‘company’]}\n\n”;
$msg .= “Message: {$_POST[‘message’]}\n\n”;
[/php]

or this:

[php]

Note the string concatenation in this version .

$to = "[email protected]";
$msg = "Name: " . $_POST[‘contact’] . “\n\n”;
$msg .= "Sender: " . $_POST[‘sender’] . “\n\n”;
$msg .= "Subject: " . $_POST[‘subject’] . “\n\n”;
$msg .= "Telephone: " . $_POST[‘telephone’] . “\n\n”;
$msg .= "Mobile: " . $_POST[‘mobile’] . “\n\n”;
$msg .= "Company Site: " . $_POST[‘company’] . “\n\n”;
$msg .= "Message: " . $_POST[‘message’] . “\n\n”;
[/php]

:wink:

If it didn’t work with POST the form is likely set to GET (the godaddy script accounts for both)

Sponsor our Newsletter | Privacy Policy | Terms of Service