We help IT Professionals succeed at work.

PHP form data not passed to email

slovisa
slovisa asked
on
278 Views
Last Modified: 2013-11-05
I have a PHP form that checks for errors and then sends the data via email. It's working perfectly on the development server - but then I uploaded it to a GoDaddy account. On the GoDaddy server, the script appears to work normally (no errors; forwards user to thankyou page, even sends the email) but the data is not passed to the email - the answers are blank.

The page is at: http://www.giftsprout.com/index_withform.php (contains all code)
Any help would be much appreciated.
Comment
Watch Question

Kiran Paul VJComputer Engineer
CERTIFIED EXPERT

Commented:
can u please post ur php code

Author

Commented:
TOP OF PAGE:
<?php
if (isset($_POST['submit'])){

$message1 = "";
$message2 = "";
$error = 0;

if (strlen($_POST['purchase'])==0){
      $message1 = "Please indicate whether you would purchase this gift basket";
      ++$error;
}
      
if (strlen($_POST['amount'])==0){
      $message2 = "Please indicate how much you would expect to pay";
      ++$error;
}

if ($error==0) {

$to = 'info@giftsprout.com';      //address to receive messages
$subject = 'Sprout Survey Response';      //subject
$content =      'Would purchase: '.$purchase."\n"
                  .'Expect to pay:  '.$amount."\n";

$headers = 'From: info@giftsprout.com' . "\r\n" . 'Bcc: steve@silverlinecreative.com' . "\r\n" . 'Reply-To: info@giftsprout.com' . "\r\n";

mail($to, $subject, $content, $headers);            //send the email
header("location: thankyou.html");            //send to thank you page
      }
      
}
?>

FORM:
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
              <?php if ($message1 != "") {echo '<span class="error">'.$message1."</span><br />\n";} ?>
              <?php if ($message2 != "") {echo '<span class="error">'.$message2."</span><br />\n";} ?>
              <?php if ($purchaseY=="yes") $purchaseY="checked='checked'";
                          if ($purchaseN=="no") $purchaseN="checked='checked'"; ?>
             
            <p>Would you purchase this gift basket?&nbsp;&nbsp;
            <input name="purchase" type="radio" $purchaseY value="yes" />Yes&nbsp;&nbsp;&nbsp;&nbsp;<input name="purchase" type="radio" $purchaseN value="no" />No</p>
            
            <p>How much would you expect to pay for this gift basket?&nbsp;&nbsp;
            <select  name="amount" value="<?php echo $amount; ?>">
                <option value="">Choose...</option>
                <option value="$16-$30">$16-$30</option>
                <option value="$31-$60">$31-$60</option>
                <option value="$61-$75">$61-$75</option>
                <option value="$75+">More than $75</option>
              </select></p>
            
              <p><input name="submit" id="submit" type="submit" value="Submit" />
        </form>
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Kiran Paul VJComputer Engineer
CERTIFIED EXPERT

Commented:
:) yes thats right, i was going to post it, just refreshed the post before posting.

In your localhost the register globals was on, but in Godaddy it was off (due to security reasons).

if register globals are on u can called a POST/GET variable by $variable name instead of $POST['$variable_name']

Author

Commented:
Thanks!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.