drog1998 Posted August 21, 2010 Share Posted August 21, 2010 HI there, i'm using a flash and php form. The problem lie in the PHP I only seem to get the field titles (Name and telephone) coming through and not the data they contain. Could somebody tell me what i'm doing wrong? <?php $sendTo = "[email protected]"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ".$strtelephone."\r\n"; $message .= "message: ".$strmessage."\r\n"; mail($sendTo, $subject, $message, $headers); ?> thank you Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/ Share on other sites More sharing options...
trq Posted August 21, 2010 Share Posted August 21, 2010 What exact data are you getting and not getting? Your problem isn't exactly described very well. Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1101988 Share on other sites More sharing options...
drog1998 Posted August 21, 2010 Author Share Posted August 21, 2010 ok no problem. All i get through are the words... telephone: message: What I want to happen is for my website to send the data from the fields labeled telephone and message in a website. so in a perfect world come thorough looking something like this... telephone: 9999 9999 message: hi drog1998 thanks again Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102001 Share on other sites More sharing options...
trq Posted August 21, 2010 Share Posted August 21, 2010 Where are $strtelephone and $strmessage defined? Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102007 Share on other sites More sharing options...
drog1998 Posted August 21, 2010 Author Share Posted August 21, 2010 i'm using Flash and each input text box has a variable name attached to it. So telephone and message are 2 of the text fields boxes. Not knowing much about PHP i've pasted the code in from somewhere else in the hope of getting it working. Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102008 Share on other sites More sharing options...
trq Posted August 21, 2010 Share Posted August 21, 2010 The examples you have been using are obviously VERY old code that relied on register globals being on. This has been off by default for over 7 years. The data you require will be within the $_POST array. eg $_POST['strtelephone'] & $_POST['strmessage']. Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102010 Share on other sites More sharing options...
drog1998 Posted August 21, 2010 Author Share Posted August 21, 2010 wow 10 years! would you mind reposting the with the new code in so i can see where it goes. I apologise as i'm very new to this. many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102011 Share on other sites More sharing options...
trq Posted August 21, 2010 Share Posted August 21, 2010 wow 10 years! I edited my post, I think its more like 7 years. Anyway, instead of $strtelephone use $_POST['strtelephone']. Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102013 Share on other sites More sharing options...
drog1998 Posted August 21, 2010 Author Share Posted August 21, 2010 i couldn't get that to work have i got the syntax right? <?php $sendTo = "[email protected]"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ". $_POST['strtelephone']"\r\n"; $message .= "message: ". $_POST['strmessage']"\r\n"; mail($sendTo, $subject, $message, $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102014 Share on other sites More sharing options...
PFMaBiSmAd Posted August 21, 2010 Share Posted August 21, 2010 Find out what data your form is sending. Add the following lines for debugging purposes (remove them when you are done) - echo "<pre>"; echo "GET:"; print_r($_GET); echo "POST:"; print_r($_POST); echo "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102015 Share on other sites More sharing options...
drog1998 Posted August 21, 2010 Author Share Posted August 21, 2010 Still nothing with this code. <?php $sendTo = "[email protected]"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; // next include a replyto $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ". $_POST['strtelephone']"\r\n"; $message .= "message: ". $_POST['strmessage']"\r\n"; mail($sendTo, $subject, $message, $headers); echo "<pre>"; echo "GET:"; print_r($_GET); echo "POST:"; print_r($_POST); echo "</pre>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102016 Share on other sites More sharing options...
PFMaBiSmAd Posted August 21, 2010 Share Posted August 21, 2010 Define: still nothing? What output did you get? You are expecting someone who is not standing right next to you to help you with what your code is doing. If you don't state or post what results you did get, no one can possibly help you. Based on your symptom of 'still nothing' it is likely that your form is invalid and isn't sending anything to your form processing code. Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102018 Share on other sites More sharing options...
trq Posted August 21, 2010 Share Posted August 21, 2010 You do have a few syntax errors in there now too... these two lines..... $message = "telephone: ". $_POST['strtelephone']"\r\n"; $message .= "message: ". $_POST['strmessage']"\r\n"; should be.... $message = "telephone: ". $_POST['strtelephone'] . "\r\n"; $message .= "message: ". $_POST['strmessage'] . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102022 Share on other sites More sharing options...
drog1998 Posted August 21, 2010 Author Share Posted August 21, 2010 ok what i meant by nothing was that i'm still getting an email through with just the words. telephone: message: here's the code again which i updated with thorpes corrections <?php $sendTo = "[email protected]"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ". $_POST['strtelephone'] . "\r\n"; $message .= "message: ". $_POST['strmessage'] . "\r\n"; mail($sendTo, $subject, $message, $headers); ?> any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102025 Share on other sites More sharing options...
trq Posted August 21, 2010 Share Posted August 21, 2010 any suggestions? Yes. Stick with PFMaBiSmAd's suggestion and post the output of.... echo "<pre>"; echo "GET:"; print_r($_GET); echo "POST:"; print_r($_POST); echo "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102026 Share on other sites More sharing options...
drog1998 Posted August 21, 2010 Author Share Posted August 21, 2010 a dumb question but where do i collect the data from? should it come through in an email? Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102027 Share on other sites More sharing options...
PFMaBiSmAd Posted August 21, 2010 Share Posted August 21, 2010 LOL, the two lines of code that thorpe pointed out with errors in them would have prevented your php code from executing at all. If you received emails while using the code that contained those two errors, then the code you are actually using on your server is not the code you have been posting. I'm thinking that using a page with a flash form on it would probably not show any output from the php code. If you are receiving some of the form data in the email but not those two values, it is either due to your form not sending the data to the php code or due to a field name mis-match. What is the actual code of your form page and what are the exact (keeping in mind that computers only do exactly what their code tells them to do and a spelling error or capitalization difference would prevent this from working) field names it is sending? I seriously recommend getting this to work with a HTML form first, then do any extras like using a flash form. Also, if this is gong to be used for real (not just an assignment in a programming class), you MUST validate, in your form processing code, any of the form data that is being put into the header field to prevent hackers from sending their email through your mail server. Quote Link to comment https://forums.phpfreaks.com/topic/211346-php-form-problem-a-newbie-question/#findComment-1102028 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.