| | |
Couple of questions
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2006
Posts: 45
Reputation:
Solved Threads: 0
Hello, I am sort of new to PHP programming. I am very familiar with C++, but i seem to be having some stupid little problems in PHP.
The code I am writing is to validate the information from a form and then email the information in the form to an email account I set up.
first problem: I have a portion of my page where the output is determined by whether or not the email is sent successfully, problem is, both the confirmation and the failure messages show up on the web browser. Somehow, both of my echo statements are making it to the web browser. What did I miss? (and this little bit of php is only a portion of the rest of the php, but this is the only part I have a problem with.)
(some HTML code here)
[php]if ($submit) { // If submit flag is 1, send mail
prepvars();
sendmail();
if ($success) { // If mail sent successfully, display confirmation
echo ("<h3 align=\"center\">Your Submit was successful. We will contact you back as soon as possible.
Thank you.</h3>");
} else { // If not successful, tell user
echo ("<h3 align=\"center\">Your Submit failed. Sorry for the inconvienience. Please Re-Submit, or try again
at a later time.</h3>");
} // End Submission Failure Warning
}[/php]
(more HTML here)
Second problem: Can someone explain the scope of variables a little better to me. My email is being sent to the email account fine, but any portions of the email that would contain variable are empty.
I have a form, then all variables are passed via POST, then in the php script they are processed and then mailed. A lot of the processing happens inside of functions, and then they are mailed by the mail() function. Why are all of my variables blank? Am I getting their scope messed up, such that I, Ideally, i want to get a local variable, but instead it grabs an empty global variable.
Final problem: is there any way to include large portions of HTML within PHP code, without having to escape every single set of quotes? Is there a program that will take code and escape all the quotes for you?
If anyone can help any of my problems, I would really appreciate it.
The code I am writing is to validate the information from a form and then email the information in the form to an email account I set up.
first problem: I have a portion of my page where the output is determined by whether or not the email is sent successfully, problem is, both the confirmation and the failure messages show up on the web browser. Somehow, both of my echo statements are making it to the web browser. What did I miss? (and this little bit of php is only a portion of the rest of the php, but this is the only part I have a problem with.)
(some HTML code here)
[php]if ($submit) { // If submit flag is 1, send mail
prepvars();
sendmail();
if ($success) { // If mail sent successfully, display confirmation
echo ("<h3 align=\"center\">Your Submit was successful. We will contact you back as soon as possible.
Thank you.</h3>");
} else { // If not successful, tell user
echo ("<h3 align=\"center\">Your Submit failed. Sorry for the inconvienience. Please Re-Submit, or try again
at a later time.</h3>");
} // End Submission Failure Warning
}[/php]
(more HTML here)
Second problem: Can someone explain the scope of variables a little better to me. My email is being sent to the email account fine, but any portions of the email that would contain variable are empty.
I have a form, then all variables are passed via POST, then in the php script they are processed and then mailed. A lot of the processing happens inside of functions, and then they are mailed by the mail() function. Why are all of my variables blank? Am I getting their scope messed up, such that I, Ideally, i want to get a local variable, but instead it grabs an empty global variable.
Final problem: is there any way to include large portions of HTML within PHP code, without having to escape every single set of quotes? Is there a program that will take code and escape all the quotes for you?
If anyone can help any of my problems, I would really appreciate it.
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
What's the value of $success?
The syntax of echo does not include ( or ).
echo "This is an echo statement.";
You can have large amounts of HTML (or even small amounts) by turning off PHP processing. Use the ?> tag to do that.
The code above has not been tested, it's merely an example.
The syntax of echo does not include ( or ).
echo "This is an echo statement.";
You can have large amounts of HTML (or even small amounts) by turning off PHP processing. Use the ?> tag to do that.
PHP Syntax (Toggle Plain Text)
if ( $file_not_found ) { ?> //Tell PHP not to process this further <font size="+2" color="red'> Not found, the file is. </font> <?php //Ok, start processing again }
The code above has not been tested, it's merely an example.
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
Oh yeah, about variable scope:
PHP doesn't treat scope like other languages. If you have a global, you have to declare it global in the function it's global. (Kinda goes against everything you think makes sense, doesn't it?) You can pass variables in via function headings, and they're always in out mode.
PHP doesn't treat scope like other languages. If you have a global, you have to declare it global in the function it's global. (Kinda goes against everything you think makes sense, doesn't it?) You can pass variables in via function headings, and they're always in out mode.
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
![]() |
Similar Threads
- Retrieve email I sent to the wrong person (Web Browsers)
- Dual booting questions (Windows Vista and Windows 7)
- NetBSD questions (*nix Software)
- Questions on Cookies (IT Professionals' Lounge)
- Some questions (PCI and Add-In Cards)
- Newbie questions about Linux servers and BSD (Getting Started and Choosing a Distro)
- Couple of CSS questions (HTML and CSS)
- Main Options / Style Questions (C++)
- connect to password protected access db (Visual Basic 4 / 5 / 6)
- 3d Program (Game Development)
Other Threads in the PHP Forum
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





