Page 1 of 2
I feel really syupid but really need some help, please!
Posted: Sun Apr 02, 2006 10:47 pm
by pixelvixen
Jcart | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
hello everyone -- I am a complete PHP newbie and I am having some real trouble with this really basic form script that's being called from Flash variables. I had it working and now it just returns the form with no inputs from the user? The mail address seems to work, the rest of the text also arrives but there are NO user inputs at all. ???
I would truly be thankful for any assistance!
(pixiexxx)
______________
Code: Select all
<?php
$sendTo = "email@address.com";
$subject = "website form reply";
$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 = $_POST["message"];
$message="An online application has been received from $name
The applicants e-mail address was: $email
State: $state
City: $city
Session date requested: $requestdate
Age: $age
Phone Number: $phone
Occupation: $occupation
The applicant agreed to terms: $terms";
mail($sendTo, $subject, $message, $headers);
?>
Jcart | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Sun Apr 02, 2006 10:54 pm
by John Cartwright
Moved to PHP-Code.
Posted: Sun Apr 02, 2006 11:01 pm
by pixelvixen
I guess it's a syntax thing?
Sorry for my lack of knowledge .. just trying to get this running!!
px.
Posted: Sun Apr 02, 2006 11:10 pm
by John Cartwright
Sounds to me like the script is being directly accessed. This is supposed to be the result of a form action.. ie
<form action="this_script.php">
or the submitted form was left blank..
try adding echo '<pre>'; print_r($_POST); echo '</pre>'; to check the contents of the form input.
Posted: Sun Apr 02, 2006 11:24 pm
by pixelvixen
Thanks jcart -- I just tried that and received nothing different.
So, is there a syntax error in my .php code above? (like a comma or something?)
It's so weird because this form wasworking wonderfully
Truly confused!
Posted: Sun Apr 02, 2006 11:38 pm
by John Cartwright
this means that
a) no form is being submitted
b) no form elements within the form exist / being filled out
Let me check, are you even submitted a form? If so, post it please.
Posted: Sun Apr 02, 2006 11:41 pm
by RobertGonzalez
Try changing your "From:" header from
Code: Select all
<?php
$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";
?>
to
Code: Select all
<?php
$headers = "From: " . $_POST["email"] ."\n";
?>
Sometimes the server you are on will handle the From and To headers differently (IIS for example chokes on the GT and LT character on some setups). Carriage returns (\r) and line feeds (\n) are sometimes handled differently as well. I moved a site from an Apache setup to an IIS setup and had to change all of my emailing functions to the second type of header listed above. Not sure if it will work but it might be worth a shot.
PS On a side note, are you making sure to run your user inputs through some type of validation? You might want to consider that.
Posted: Mon Apr 03, 2006 1:23 am
by pixelvixen
Thanks for these helpful solves -- I'm using flash (yes, I can see you all rolling your eyes!) to create the content so the AS in Flash is what's driving this. The thing is on my server, it sends variables no problem, on th client side it sends everything but the inputs??
I have tried the headers fix as above -- it stayed true and sent me the email address of the user, but still it seems that variables aren't being sent.
Much gratitude for any more support - having it work on one server and not on another is making me nutty!
xx
Posted: Mon Apr 03, 2006 1:34 am
by John Cartwright
oops sorry I completely misunderstood the question..
First add this to your code
Secondly, what versions of PHP are the two servers running?
Thirdly, try this on your server which is not using the script properly,
Code: Select all
echo '<pre>'; print_r($HTTP_POST_VARS); echo '</pre>';
Posted: Mon Apr 03, 2006 1:43 am
by RobertGonzalez
How are the user input variables being set ($email, $state, $city, etc). Are you setting these to their $_POST equivalents?
Posted: Mon Apr 03, 2006 2:12 am
by pixelvixen
feyd | Please use Code: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks so much again -- I am really happy there is 'someone' who can help this girl figure all this out!!
So, I tried this code just after my open <php tag (??) and still the same result. I changed the server that isn't recognising my variables to PHP V5.0 and that hasn't fixed this either !!
It is odd because it seems that only the variables in the "$message" aren't coming through, everything else (like the email headers) are coming through OK. And, as I said before it seems to work fine on my other server -- variables and all.
here's the .php again.
Code: Select all
<?php
echo '<pre>'; print_r($HTTP_POST_VARS); echo '</pre>';
$sendTo = "email@address.com";
$subject = "Online Application";
$headers = "From: " . $_POST["email"] ."\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-path: " . $_POST["email"];
$message = $_POST["message"];
$message = "An online application was received from: $nameform
The applicants e-mail address was: $email
State: $state
City: $city
Session date requested: $requestdate
Age: $age
Phone Number: $phone
Occupation: $occupation
The applicant agreed to terms: $terms";
mail($sendTo, $subject, $message, $headers);
?>
feyd | Please use Code: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Mon Apr 03, 2006 2:32 am
by RobertGonzalez
pixelvixen wrote:It is odd because it seems that only the variables in the "$message" aren't coming through
Code: Select all
<?php
$message = "An online application was received from: $nameform
The applicants e-mail address was: $email
State: $state
City: $city
Session date requested: $requestdate
Age: $age
Phone Number: $phone
Occupation: $occupation
The applicant agreed to terms: $terms";
?>
Post the code that sets these vars. Also, post the names of the form fields (AS you said it was, right?) that pass this data. It might just be that register_globals is off (which it should be) and that you are not setting these vars to their $_POST values. But post the code so we can see it.
Posted: Mon Apr 03, 2006 7:15 am
by pixelvixen
OK, so here's the code from Flash .. not sure it's useful to you?
Code: Select all
on (release) {
// send variables in form movieclip (the textfields)
// to email PHP page which will send the mail
form.loadVariables("email2.php", "POST");
}
I have numerous VARIABLES on my stage that are named "occupation","state", etc ..
These vars all corelate to those named "occupation", "$state", etc .. in the .php script. All these vars are contained in a Movie Clip called "form" This comman calls on all vars in the form (movie clip) and groups them together for sending?
It is my understanding (which is probably wrong!) that, all these vars are grouped together and sent with the loadVariables command in flash. As I may have said ..
this works perfectly on one server and not on another -- both using PHP version 4.0
HUGE thanks for your help everyone!!!

Posted: Mon Apr 03, 2006 8:19 am
by RobertGonzalez
pixelvixen wrote:As I may have said .. this works perfectly on one server and not on another -- both using PHP version 4.0
OK, now the question..
Are you setting the PHP variable $occupation (or $state or $city) equal to $_POST['occupation']? Something like this...
Code: Select all
<?php
$occupation = $_POST['occupation'];
$state = $_POST['state'];
$city = $_POST['city'];
?>
... before you try to use these vars in the email message? If the php.ini directive
register_globals is off on the server you are having this problem with, without setting the value of the vars to their post equivalents these vars will be empty (essentially undeclared vars). If everything in the script works except the capturing of the values for the vars in the message portion I would bet that register_globals is off and that the message vars are not being set to anything.
Posted: Mon Apr 03, 2006 6:16 pm
by pixelvixen
Oooh this is very exciting!! THANK YOU! __ So are you saying I have to either turn register_globals ON at the server or somehow add $_POST['occupation'] etc to all the vars? If so, I was under the impression you could only put up to 5 vars in the mail($subject, $message, etc ... ) part of the script??
OOh so happy -- me thanking you long time! Will try to turn register_globals ON now ..