Archive for November, 2007

705Chapter 38PHP and JavaScriptEven (Web hosts) this example doesn t show

Friday, November 16th, 2007

705Chapter 38PHP and JavaScriptEven this example doesn t show the fullest extent of PHP/JavaScript separation. A lot ofJavaScript is actually defined within the element of an HTML page and simply calledin the , whereas PHP is generally used in the latter. As with HTML, there are occasions when you don t want to escape from PHP or this stylemay just be your personal preference. In that case, you can use PHP s echoor printstate- ments to output JavaScript. n ); echo( n ); echo( n ); echo( More PHP in this block. ); ?> You may run into trouble if you use script tags (for instance, ) todelineate PHP chunks the PHP parser may have a hard time figuring out which tag goes with what
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Web hosting account - PHP and JavaScriptIn this chapter, we try to

Wednesday, November 14th, 2007

PHP and JavaScriptIn this chapter, we try to get the best of both client-side and server- side scripting by combining PHP with JavaScript. We briefly touchupon the question of when to use which scripting language, andstylistic points that may be helpful when writing the code. Then wemove on to pragmatic examples of the type you might see on a real- world PHP site. If you ve never worked with JavaScript before, you won t learnhow just by reading this chapter. We will only touch on aspects ofJavaScript that materially impinge upon PHP. If you re wonderingwhat an onBlurevent is, we recommend Danny Goodman ssuperlative JavaScript Bible, Fifth Edition(Wiley, 2004). Outputting JavaScript with PHPBecause PHP is server-side and JavaScript is client-side, you mayexpect to have problems using both on the same page. In actuality, it s the difference that makes them such a good match. Although PHP offers plenty of power for creating dynamically gener- ated Web pages, it is strictly a server-side language. There s a com- mon category of Web site tasks that perhaps don t require all theprocessing power of a server and would best be done quickly forinstance, changing the look of a button on mouseover. JavaScript, apurely client-side language (there s a server-side version, but we reassuming you ve already chosen PHP on that end), can be easily inte- grated into PHP to fill in many of these gaps. On the other hand, client-side JavaScript (aka Javascript, JScript, ECMAScript) itself has many limitations. For example, because itcan t communicate directly with a database, JavaScript cannot updateitself with fresh data depending on the page. Even worse, it s impossi- ble to depend on client-side technologies, because they may not bepresent in a visitor s browser or may be disabled. Conscientiousclient-side Web developers must either decide to code probabilisti- cally (and accept complaints from minority-browser users) or main- tain several versions of a site at the same time. (Nonconscientiousdevelopers simply adapt themselves to the market-leading browser sfull capabilities and damn the torpedoes . . . but that s another story.) PHP can help to mitigate the effects of client-side indeterminacy. Tip3838CHAPTER …In This ChapterOutputting JavaScriptwith PHPPHP as backup forJavaScriptStatic versus dynamicJavaScriptDynamic formgeneration …
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

701Chapter 37E-mailE-mail GotchasGiven that there are so (Web design conference) few

Wednesday, November 14th, 2007

701Chapter 37E-mailE-mail GotchasGiven that there are so few mail-related functions in PHP, and these are very straightforward, e-mail related issues are highly likely to be caused by problems with the mail servers or evenwith the protocols themselves. In our experience, there is little a PHP developer can do to fixmail problems that suddenly arise in a working PHP installation. If you experience a mail-related error message in PHP, the first thing you want to do is sendand receive mail using the sendmailserver that your PHP installation points to just toeliminate the possibility that your SMTP server is totally hosed. Next, make sure that you have set the sendmailor SMTP path in your configuration files correctly. Remember that you will have to do this every time you upgrade your PHP and/orWeb server binary. Even if you re positive you did it correctly, it doesn t hurt to check again. Remember that there may be multiple configuration files for instance, php.iniandApache s httpd.confcan both be used to set the sendmailpath. If you don t see an error message and some of your e-mails are getting through, see if you can find a common denominator in the failure cases. For instance, it s quite common for well- managed mail servers to refuse delivery of e-mail from servers that do not pass a reverse-DNSlookup check. If your sendmailaliasing is configured incorrectly, the name or private-networkIP address of a non-public machine inside your firewall might be making it into your mailheaders leading to a quick bounce from some of the better-administered SMTP servers(typically corporations and the more technical universities). Another common problem canoccur when you forget to change the default PHP mail sending user, or have it set to a usersuch as nobodyor root many well-managed SMTP servers will refuse mail from these users. If your problem is with POP or IMAP accounts accessed via a PHP client, try waiting a whileto see if matters improve on the server end. These servers are notoriously flaky, and not onlycrash a lot, but require an unusual amount of scheduled maintenance. This is frustrating buttotally outside the realm of anything most Web developers are responsible for. Finally, if you are having problems with sending attachments with PHP, check out the docu- mentation (including code comments) that shipped with the MIME mail class you re using. Fiddly little issues with things like line breaks and timestamps and multiple addresses maybecausing you problems. SummaryE-mail is one of the most useful and attractive functions of the Internet. PHP gives you theability to both send and receive e-mail from a Web page. However, PHP is not a specializede-mail program and will not cope gracefully with large numbers of messages. Unfortunately, e-mail is one of the more complicated services in most domains, with a largenumber of moving parts and a surprising lack of standardization for such a relatively long- established functionality. Do not blame this on PHP it s inherent in e-mail itself. One of the most common uses of PHP s mailfunction is to send an e-mail (often to yourself) with values generated from a Web form. This is more reliable and spam-resistant than a mailtolink, and it allows you to impose more structure on the data. You can also use PHP to send offsmall batches of e-mail using data from a database. However, large batches require a mailing- list manager or other solution. …
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Virtual web hosting - 700Part IVConnectionsListing 37-8(continued) $from = mailbot@example.com ; $subject =

Tuesday, November 13th, 2007

700Part IVConnectionsListing 37-8(continued) $from = mailbot@example.com ; $subject = Evaluation software license expires ; $msg = You downloaded our evaluation software 45 daysago. Now you should pay us, or it will self-destruct. ; $mailsend = mail($to, $subject, $msg, From: $from ); $send_info_email_arr .= n .$to. n ; } // Send me some email to let me know what happened$info_msg .= I sent mail to the following evaluatorstoday:

n ; $info_msg .= print_r($send_info_email_arr); $info_mail = mail( webdev@example.com , Cron job for$target_date , $info_msg, From: cronjob@example.com ); } else { // If there were no recipients today, let me know that$info_msg = I didn t find anyone to send mail to today. ; $info_mail = mail( webdev@example.com , Cron job for$target_date , $info_msg, From: cronjob@example.com ); } ?> Save this file in a location and with permissions that allow the PHP binary user to run it. Now you need to schedule your cronjob. Say we want to send this mail out once a day at3:15 a.m., the slowest hour of the day for your Web servers. Open up your crontab(typecrontab-ein a shell) and enter this line (make sure your Unix user can execute the PHPbinary): 15 03 * * * /usr/local/bin/php /home/phpcrons/nagmail.phpReading from left to right, the various notations stand for minute, hour, day, month, day ofweek, and the command to be executed. (Asterisks are wildcards.) So this line tells the crondaemon to wake up and tap the PHP binary to run the nagmail.phpscript at 3:15 a.m. everymorning of the year. So sad for Windows users, but this is not possible with PHP in your operating system. Unixhas a lot of functionality in the system layer that Windows tends to put in the applicationlayer so for instance Unix programmers constantly use the greputility to search for a stringin a set of files, which Windows programmers accomplish in the IDE. Similarly, scheduling arepetitive task like sending automatic e-mail is done in Outlook on Windows or as a triggerfrom SQL Server, rather than via a cronjob. Caution42
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Remote web server - 699Chapter 37E-mailSending mail from a cronjobIn the preceding

Monday, November 12th, 2007

699Chapter 37E-mailSending mail from a cronjobIn the preceding examples, mail is triggered by the action of a human being interacting with aWeb form. Sometimes, though, you want to send a batch of e-mail periodically and automati- cally. This is where Unix comes in handy just set up a cronjobwith PHP. It is a very happyfeeling to drift off to sleep knowing that your little automatons are still working hard for you. A very common use of a cronjobis to send a batch of e-mail in the middle of the night. Notonly does this mean your mail will be waiting for the user at the top of the queue in the morn- ing, but the dark hours before dawn are the traditional and best time to schedule batch pro- cesses that might slow down your servers. To schedule a cronjob, first you write a script in the language of your choice. In this case, we are going to use the standalone version of PHP the one that is not a module of any Webserver. The script in Listing 37-8 (nagmail.php) sends out a reminder to everyone who down- loaded an evaluation license 45 days ago. Listing 37-8:Mail script for cron (nagmail.php) = $target_date 00:00:00 AND sent_date <= $target_date 23:59:59 ; $result = mysql_query($query,$db); if (mysql_num_rows($result) > 0) { while ($email_arr = mysql_fetch_array($result)) { $to = $email_arr[0]; Continued42
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Top web site - 698Part IVConnectionsListing 37-6(continued) $formsent = mail($Email, Login and

Monday, November 12th, 2007

698Part IVConnectionsListing 37-6(continued) $formsent = mail($Email, Login and password info , Your login is: $FirstName $LastName.rnMake sure there is only one space between the two words when youlog in.rnYour password is: $Password.nGood luck! , From: mailinglist@sendhostrnReply-to: help@sendhost ); echo The result is $formsent for $list_length.
n ; } ?> Listing 37-7 is the password generation file, password_maker.inc. Listing 37-7:Random password generation functions(password_maker.inc)
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Web host sites - 697Chapter 37E-mailnE-mail Address: n ); } ?> Listing 37-6

Sunday, November 11th, 2007

697Chapter 37E-mail
nE-mail Address: n ); } ?>

Listing 37-6 is the form handler, email_send.php. Listing 37-6:Batch e-mail form handler (email_send.php) 0; $list_length <= 24 && strlen($_POST[ Email ][$list_length]) > 0; $list_length++) { // 8 is the number of characters desired in each password. $Password = random_string($charset, 8) ; $FirstName = $_POST[ FirstName ][$list_length]; $LastName = $_POST[ LastName ][$list_length]; $Email = $_POST[ Email ][$list_length]; $query = INSERT INTO recipient(FirstName, LastName, Email, Password) VALUES( $FirstName , $LastName , $Email , $Password) ; $result = mysql_query($query); Continued42
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

696Part IVConnectionsA custom PHP mail applicationVarious organizations have (My space web page)

Saturday, November 10th, 2007

696Part IVConnectionsA custom PHP mail applicationVarious organizations have their own special needs, for which you might be called upon todesign a custom gizmo. For instance, here is a not-uncommon situation in which a custommail application might be appropriate: .The client wants to send personalized e-mail messages, each containing a password, toseveral hundred people. .The client will enter each name and e-mail address by hand into a form from hardcopy. The program will insert this data into a database, along with passwords generated by PHP. .PHP will compose and send a batch of e-mail using boilerplate text. Listings 37-5, 37-6, and 37-7 show the code for a sample application to meet these specs. Itcombines the functionality of the two previous code samples and adds a couple of twistssuch as arrays and a random password generator (based on an example from Chapter 10). Listing 37-5 is the entry form, address_entry.php. Listing 37-5:Batch e-mail entry form (address_entry.php) address_entry.php

Enter the names and e-mail addresses of recipients on this page. You do not have to complete all 25 entries. When you are readyto actually send the e-mails, click the Submit button at thebottom of the page.

First name:
nLast name:
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

695Chapter 37E-mailIn Listing 37-4, we ll send a license (Florida web design)

Saturday, November 10th, 2007

695Chapter 37E-mailIn Listing 37-4, we ll send a license file for an evaluation software download to anyone whorequests one via a Web form. Listing 37-4:Send e-email with a text attachment (send_license.php) 40) { echo Bad string ; exit; } include( htmlMimeMail.php ); $mail = new htmlMimeMail(); $attachment = $mail->getFile( eval_license.lic ); $mailbody = $mail->getFile( license_email.txt ); $mail->setText($mailbody); $mail->addAttachment($attachment, eval_license.lic , text/plain ); $mail->setReturnPath( mailbot@example.com ); $mail->setFrom( mailbot@example.com ); $mail->setSubject( Evaluator ); $mail->send(array($_POST[ email ]), smtp ); } else { $form_str = <<< EOFORM EOFORM; echo $form_str; } ?>
We recommend high quality webhost to host and run your jsp application: christian web host services.