[PHP] Re: PHP Variable Declare
try: if (isset($_POST['frmAction']) $_POST['frmAction'] == formmail) instead of your line. Thomas On Wed, 22 Jan 2003 09:47:46 -0500 [EMAIL PROTECTED] (Stephen Goehler) wrote: Hey guys, Thanks in advance for your help. I'm working on emailing the contents of a form using php. It worked fine, until I turned global_variables off in an attempt to secure the form (I still have yet to write the data validation part). Anyway, I have an IF statement that fires depending on a hidden variable in the form. If the variable is empty, it loads the form. If the variable contains the hidden value I give it during form creation, then it emails the contents on the form and displays a thank you msg instead of displaying the form. The problem I have run into, involves the hidden value for the form. I didn't have to declare it before when I had global_variables turned on, but now I have to. I searched the manual and tried statements like global $variablename but the code wouldn't run properly. I've searched through the newsgroups as well, but I'm new to PHP so it was tough to figure out what to search for. I'm sure all I'm missing is one line of code. I included my code below. The problem exists in this line: if ($_POST['frmAction'] == formmail) which is before where the form is created so the $frmAction variable isn't declared yet. I'm getting a variable not declared error, which I know, but if I declare the variable earlier in the document, then it resets the value that I give it before I submit the form. How do I make this work? Thanks so very much!! Steve html head /head body **HTML stuff here** ?php // error handler function e($type, $msg, $file, $line) { $errorLog = error.log; **Error Handler code here** } error_reporting(E_ERROR | E_WARNING); set_error_handler(e); $TO = [EMAIL PROTECTED]; $MP = mail.mailserver.com; ? ?php if ($_POST['frmAction'] == formmail) { $fd = popen($MP,w); fputs($fd, To: $TO\n); fputs($fd, From: $_POST['name'] $_POST['email']\n); fputs($fd, Subject: $_POST['inforequest']\n); fputs($fd, X-Mailer: PHP3\n); fputs($fd, Name: $_POST['name']\n); fputs($fd, Business: $_POST['business']\n); fputs($fd, Phone: $_POST['phone']\n); fputs($fd, Email: $_POST['email']\n); fputs($fd, Details: $_POST['details']); pclose($fd); ? **HTML thank you msg here** ?php exit; } else { ? table form action=test.php method=POST select name=inforequest optionSelect Info Source/option option value=Option 1Option 1/option option value=Option 2Option 2/option option value=Option 3Option 3/option option value=Option 4Option 4/option /select /td /tr tr input type=text name=name /td /tr tr input type=text name=business /td /tr tr input type=text name=phone /td /tr tr input type=text name=email /td /tr tr textarea name=details wrap=PHYSICAL cols=35 rows=8/textarea /td /tr tr td input type=hidden name=frmAction value=formmail input type=submit name=Submit value=Submit input type=reset name=Reset value=Reset /td /tr /form /table ?php } ? **last bit of HTML here** /body /html -- Thomas Seifert mailto:[EMAIL PROTECTED] http://www.MyPhorum.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Variable Declare
Now it gets more confusing.I added: print 'pre'; print_r($_POST); print '/pre'; to my form and the variables are displayed properly, but only generate errors when I try to add it to fputs().any ideas? Stephen Goehler [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Thanks!! That worked perfectly. Neat little function there to check if a variable exists. Also I am set to E_ERROR ~E_NOTICE already. The form loads correctly and then when you click submit goes to the thank you screen. The only problem now is that it says that my variables don't exist that I pass using the form and as a result, won't email them. When it gets to the code to email the results the variables like $_POST['name'] won't exist. What puzzles me is that the frmAction is passed, but none of the textbox...etc. variables are. Do I need to add in the form name somewhere to show where the variables are coming from? Thomas Seifert [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... try: if (isset($_POST['frmAction']) $_POST['frmAction'] == formmail) instead of your line. Thomas On Wed, 22 Jan 2003 09:47:46 -0500 [EMAIL PROTECTED] (Stephen Goehler) wrote: Hey guys, Thanks in advance for your help. I'm working on emailing the contents of a form using php. It worked fine, until I turned global_variables off in an attempt to secure the form (I still have yet to write the data validation part). Anyway, I have an IF statement that fires depending on a hidden variable in the form. If the variable is empty, it loads the form. If the variable contains the hidden value I give it during form creation, then it emails the contents on the form and displays a thank you msg instead of displaying the form. The problem I have run into, involves the hidden value for the form. I didn't have to declare it before when I had global_variables turned on, but now I have to. I searched the manual and tried statements like global $variablename but the code wouldn't run properly. I've searched through the newsgroups as well, but I'm new to PHP so it was tough to figure out what to search for. I'm sure all I'm missing is one line of code. I included my code below. The problem exists in this line: if ($_POST['frmAction'] == formmail) which is before where the form is created so the $frmAction variable isn't declared yet. I'm getting a variable not declared error, which I know, but if I declare the variable earlier in the document, then it resets the value that I give it before I submit the form. How do I make this work? Thanks so very much!! Steve html head /head body **HTML stuff here** ?php // error handler function e($type, $msg, $file, $line) { $errorLog = error.log; **Error Handler code here** } error_reporting(E_ERROR | E_WARNING); set_error_handler(e); $TO = [EMAIL PROTECTED]; $MP = mail.mailserver.com; ? ?php if ($_POST['frmAction'] == formmail) { $fd = popen($MP,w); fputs($fd, To: $TO\n); fputs($fd, From: $_POST['name'] $_POST['email']\n); fputs($fd, Subject: $_POST['inforequest']\n); fputs($fd, X-Mailer: PHP3\n); fputs($fd, Name: $_POST['name']\n); fputs($fd, Business: $_POST['business']\n); fputs($fd, Phone: $_POST['phone']\n); fputs($fd, Email: $_POST['email']\n); fputs($fd, Details: $_POST['details']); pclose($fd); ? **HTML thank you msg here** ?php exit; } else { ? table form action=test.php method=POST select name=inforequest optionSelect Info Source/option option value=Option 1Option 1/option option value=Option 2Option 2/option option value=Option 3Option 3/option option value=Option 4Option 4/option /select /td /tr tr input type=text name=name /td /tr tr input type=text name=business /td /tr tr input type=text name=phone /td /tr tr input type=text name=email /td /tr tr textarea name=details wrap=PHYSICAL cols=35 rows=8/textarea /td /tr tr td input type=hidden name=frmAction value=formmail input type=submit name=Submit value=Submit
[PHP] Re: PHP Variable Declare
it won't work the way you are doing this. Try something like that line (changed from yours): fputs($fd, From: .$_POST['name']. .$_POST['email'].\n); Don't ask arrays directly in a string. Thomas On Wed, 22 Jan 2003 11:15:35 -0500 [EMAIL PROTECTED] (Stephen Goehler) wrote: Now it gets more confusing.I added: print 'pre'; print_r($_POST); print '/pre'; to my form and the variables are displayed properly, but only generate errors when I try to add it to fputs().any ideas? Stephen Goehler [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Thanks!! That worked perfectly. Neat little function there to check if a variable exists. Also I am set to E_ERROR ~E_NOTICE already. The form loads correctly and then when you click submit goes to the thank you screen. The only problem now is that it says that my variables don't exist that I pass using the form and as a result, won't email them. When it gets to the code to email the results the variables like $_POST['name'] won't exist. What puzzles me is that the frmAction is passed, but none of the textbox...etc. variables are. Do I need to add in the form name somewhere to show where the variables are coming from? Thomas Seifert [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... try: if (isset($_POST['frmAction']) $_POST['frmAction'] == formmail) instead of your line. Thomas On Wed, 22 Jan 2003 09:47:46 -0500 [EMAIL PROTECTED] (Stephen Goehler) wrote: Hey guys, Thanks in advance for your help. I'm working on emailing the contents of a form using php. It worked fine, until I turned global_variables off in an attempt to secure the form (I still have yet to write the data validation part). Anyway, I have an IF statement that fires depending on a hidden variable in the form. If the variable is empty, it loads the form. If the variable contains the hidden value I give it during form creation, then it emails the contents on the form and displays a thank you msg instead of displaying the form. The problem I have run into, involves the hidden value for the form. I didn't have to declare it before when I had global_variables turned on, but now I have to. I searched the manual and tried statements like global $variablename but the code wouldn't run properly. I've searched through the newsgroups as well, but I'm new to PHP so it was tough to figure out what to search for. I'm sure all I'm missing is one line of code. I included my code below. The problem exists in this line: if ($_POST['frmAction'] == formmail) which is before where the form is created so the $frmAction variable isn't declared yet. I'm getting a variable not declared error, which I know, but if I declare the variable earlier in the document, then it resets the value that I give it before I submit the form. How do I make this work? Thanks so very much!! Steve html head /head body **HTML stuff here** ?php // error handler function e($type, $msg, $file, $line) { $errorLog = error.log; **Error Handler code here** } error_reporting(E_ERROR | E_WARNING); set_error_handler(e); $TO = [EMAIL PROTECTED]; $MP = mail.mailserver.com; ? ?php if ($_POST['frmAction'] == formmail) { $fd = popen($MP,w); fputs($fd, To: $TO\n); fputs($fd, From: $_POST['name'] $_POST['email']\n); fputs($fd, Subject: $_POST['inforequest']\n); fputs($fd, X-Mailer: PHP3\n); fputs($fd, Name: $_POST['name']\n); fputs($fd, Business: $_POST['business']\n); fputs($fd, Phone: $_POST['phone']\n); fputs($fd, Email: $_POST['email']\n); fputs($fd, Details: $_POST['details']); pclose($fd); ? **HTML thank you msg here** ?php exit; } else { ? table form action=test.php method=POST select name=inforequest optionSelect Info Source/option option value=Option 1Option 1/option option value=Option 2Option 2/option option value=Option 3Option 3/option option value=Option 4Option 4/option /select /td /tr tr input type=text name=name /td /tr tr input type=text name=business /td /tr tr input type=text name=phone /td /tr tr
[PHP] Re: PHP Variable Declare
Thanks guys for helping out. I got it working now! Thomas Seifert [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... it won't work the way you are doing this. Try something like that line (changed from yours): fputs($fd, From: .$_POST['name']. .$_POST['email'].\n); Don't ask arrays directly in a string. Thomas On Wed, 22 Jan 2003 11:15:35 -0500 [EMAIL PROTECTED] (Stephen Goehler) wrote: Now it gets more confusing.I added: print 'pre'; print_r($_POST); print '/pre'; to my form and the variables are displayed properly, but only generate errors when I try to add it to fputs().any ideas? Stephen Goehler [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Thanks!! That worked perfectly. Neat little function there to check if a variable exists. Also I am set to E_ERROR ~E_NOTICE already. The form loads correctly and then when you click submit goes to the thank you screen. The only problem now is that it says that my variables don't exist that I pass using the form and as a result, won't email them. When it gets to the code to email the results the variables like $_POST['name'] won't exist. What puzzles me is that the frmAction is passed, but none of the textbox...etc. variables are. Do I need to add in the form name somewhere to show where the variables are coming from? Thomas Seifert [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... try: if (isset($_POST['frmAction']) $_POST['frmAction'] == formmail) instead of your line. Thomas On Wed, 22 Jan 2003 09:47:46 -0500 [EMAIL PROTECTED] (Stephen Goehler) wrote: Hey guys, Thanks in advance for your help. I'm working on emailing the contents of a form using php. It worked fine, until I turned global_variables off in an attempt to secure the form (I still have yet to write the data validation part). Anyway, I have an IF statement that fires depending on a hidden variable in the form. If the variable is empty, it loads the form. If the variable contains the hidden value I give it during form creation, then it emails the contents on the form and displays a thank you msg instead of displaying the form. The problem I have run into, involves the hidden value for the form. I didn't have to declare it before when I had global_variables turned on, but now I have to. I searched the manual and tried statements like global $variablename but the code wouldn't run properly. I've searched through the newsgroups as well, but I'm new to PHP so it was tough to figure out what to search for. I'm sure all I'm missing is one line of code. I included my code below. The problem exists in this line: if ($_POST['frmAction'] == formmail) which is before where the form is created so the $frmAction variable isn't declared yet. I'm getting a variable not declared error, which I know, but if I declare the variable earlier in the document, then it resets the value that I give it before I submit the form. How do I make this work? Thanks so very much!! Steve html head /head body **HTML stuff here** ?php // error handler function e($type, $msg, $file, $line) { $errorLog = error.log; **Error Handler code here** } error_reporting(E_ERROR | E_WARNING); set_error_handler(e); $TO = [EMAIL PROTECTED]; $MP = mail.mailserver.com; ? ?php if ($_POST['frmAction'] == formmail) { $fd = popen($MP,w); fputs($fd, To: $TO\n); fputs($fd, From: $_POST['name'] $_POST['email']\n); fputs($fd, Subject: $_POST['inforequest']\n); fputs($fd, X-Mailer: PHP3\n); fputs($fd, Name: $_POST['name']\n); fputs($fd, Business: $_POST['business']\n); fputs($fd, Phone: $_POST['phone']\n); fputs($fd, Email: $_POST['email']\n); fputs($fd, Details: $_POST['details']); pclose($fd); ? **HTML thank you msg here** ?php exit; } else { ? table form action=test.php method=POST select name=inforequest optionSelect Info Source/option option value=Option 1Option 1/option option value=Option 2Option 2/option option value=Option 3Option 3/option option value=Option 4Option 4/option /select /td /tr tr input type=text name=name /td