User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,550 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,565 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 630 | Replies: 2
Reply
Join Date: May 2006
Posts: 45
Reputation: petzoldt01 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
petzoldt01 petzoldt01 is offline Offline
Light Poster

Couple of questions

  #1  
Aug 27th, 2006
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Location: North East Indiana
Posts: 491
Reputation: Puckdropper is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 20
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: Couple of questions

  #2  
Aug 27th, 2006
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.

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.
Reply With Quote  
Join Date: Jul 2004
Location: North East Indiana
Posts: 491
Reputation: Puckdropper is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 20
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: Couple of questions

  #3  
Aug 27th, 2006
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.
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:17 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC