verdipro Posted July 11, 2008 Share Posted July 11, 2008 Hello, I am brand new to this forum & semi-new to PHP. I am looking to enhance my PHP knowledge & hopefully help other fellow members when I can & it looks like I came to the right place to do both. I am having an issue with a form that I have used on my PHP enabled sites. It has worked on every server until this new server that I am posting this form on. My web host tells me that this server is PHP4 in suexec mode (not sure what that means). Below I have copied my code from my contact.php page. When I submit the form I get the email, I even get the form field names, but the email contains none of the information that was typed into the form boxes. <? $msg = "Name:\t$_POST['name']\n"; $msg .= "Telephone:\t$_POST['phone']\n"; $msg .= "Email:\t$_POST['email']\n"; $msg .= "How do you wish to be contacted?:\t$_POST['contacted']\n"; $msg .= "Comments:\t$_POST['comments']\n"; $to = "email@domainname.com"; $subject = "Contact Us"; $mailheaders = "From: email@domainname.com <> \n"; mail($to, $subject, $msg, $mailheaders); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Web Site Title</title> </head> <body> <meta http-equiv="Refresh" content="0; url=thankyou.htm"> </body> </html> If anyone has any ideas on what could be causing this issue, it would be greatly appreciated. This has been a tough one for me to figure out. Quote Link to comment https://forums.phpfreaks.com/topic/114317-form-issue/ Share on other sites More sharing options...
craygo Posted July 11, 2008 Share Posted July 11, 2008 is the form using GET or POST method give code for form also. Ray Quote Link to comment https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587855 Share on other sites More sharing options...
sasa Posted July 11, 2008 Share Posted July 11, 2008 try <? $msg = "Name:\t$_POST[name]\n"; $msg .= "Telephone:\t$_POST[phone]\n"; $msg .= "Email:\t$_POST[email]\n"; $msg .= "How do you wish to be contacted?:\t$_POST[contacted]\n"; $msg .= "Comments:\t$_POST[comments]\n"; $to = "email@domainname.com"; $subject = "Contact Us"; $mailheaders = "From: email@domainname.com <> \n"; mail($to, $subject, $msg, $mailheaders); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Web Site Title</title> </head> <body> <meta http-equiv="Refresh" content="0; url=thankyou.htm"> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587858 Share on other sites More sharing options...
86Stang Posted July 11, 2008 Share Posted July 11, 2008 Would register_globals setting have anything to do with it? Quote Link to comment https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587862 Share on other sites More sharing options...
craygo Posted July 11, 2008 Share Posted July 11, 2008 It shouldn't since he is using the actual post values. Also the he has the correct way $_POST['name']. Best practice is to keep strings for array keys in single or double quotes. But I guess on some servers you can call the array values right in the double quotes. I know it does not work on my server, I have to come out of the quotes or enclose them in brackets $msg = "Name:\t{$_POST['name']}\n"; or $msg = "Name:\t".$_POST['name']."\n"; Maybe someone can clarify this On my box this works fine $msg = "hello $name, how are you"; but this won't $msg = "hello $_POST['name'], how are you"; Ray Quote Link to comment https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587866 Share on other sites More sharing options...
verdipro Posted July 11, 2008 Author Share Posted July 11, 2008 thanks for all of the replies. sasa that worked great & the form now works. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587869 Share on other sites More sharing options...
sasa Posted July 11, 2008 Share Posted July 11, 2008 <?php $array = array('a'=> 11, 'b' => 'sasa'); echo " it is OK {$array['a']}"; //echo " it is not OK $array['a']";// array key not have '' echo " it is OK $array[a]"; $key = 'a'; echo " it is OK {$array[$key]}"; echo " it is OK $array[$key]"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587878 Share on other sites More sharing options...
craygo Posted July 11, 2008 Share Posted July 11, 2008 Got ya, I figured that out when testing what you posted. Just goes all to hell if there is a space in the key. That is why I will stick to keeping the quotes and brackets. Just makes me feel better. Works <?php $_POST['name man'] = "Ray"; $msg = "Hello {$_POST['name man']} How are you"; echo $msg; ?> no soup for you <?php $_POST['name man'] = "Ray"; $msg = "Hello $_POST[name man] How are you"; echo $msg; ?> Ray Quote Link to comment https://forums.phpfreaks.com/topic/114317-form-issue/#findComment-587883 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.