Web design course - However, to ensure that you get the first

However, to ensure that you get the first value in the $postcard array regardless of the key, you use the foreach() loop. You must use the if statement because if there is no $postcard array, foreach() returns an invalid argument warning. Yes, we know that currently a postcard value is always posted to the sendconf.php page, but if you make a change to postcard.php (for instance, to make the postcard image optional), you don t want sendconf.php to break, right? Let s move on. Your sendconf.php script performs an extra step you did not take care of in sendmail.php. You must temporarily store the postcard data while you await confirmation. $temp = gettimeofday(); $msec = (int) $temp[ usec ]; $msgid = md5(time() . $msec); Note the use of a new PHP function, md5().This returns a 128-bit fingerprint, or hash, of the message passed to it. For example, the md5 hash of Hello World is b10a8db164e0754105b7a99be72e3fe5. It is designed as a one-way encryption of the data passed in to it, so you cannot reverse it to discover the original value. Using a one-way hash in this manner allows you to safely have the user click on a link in their e-mail to view their postcard. If you had used a simple number or keyword, a malicious user could more easily guess the URL, and ruin all your fun guessing an md5 hash would take too long to make it worthwhile for the hacker. By passing in a time value, you can be fairly certain that the md5 hash returned will be a unique value, which you use as a unique ID for the data. It is not 100 percent guaranteed to be unique, but because it is generated based on the current time in seconds and contains 32 alphanumeric characters, you can be reasonably sure it will be unique. If you are interested in finding out more information about the md5 hash, visit RFC 1321: The MD5 Message-Digest Algorithm at www.faqs.org/rfcs/rfc1321. require( ./includes/conn_comic.php ); $sql = INSERT INTO confirm (validator, to_email, toname, from_email, . fromname, bcc_email, cc_email, subject, postcard, message) . VALUES ( $msgid , $to , $toname , $from , . $fromname , $bcc , $cc , $subject , $postcard , $messagebody ) ; $query = mysql_query($sql, $conn) or die(mysql_error()); Next, you store the postcard data temporarily until it is validated. When the user clicks the confirmation link in the e-mail to send it, the postcard is sent on to its intended recipient. $confirmsubject = Please Confirm your postcard ; $confirmmessage = Hello . $fromname . ,nn ; $confirmmessage .= Please click on the link below to confirm that . you would like to send this postcard:nn ; $confirmmessage .= $html_msg . nn ; $confirmmessage .= Click here to confirm ; $textconfirm = Hello . $fromname . ,nn ; $textconfirm .= Please visit the following URL to confirm your . postcard:nn ; $textconfirm .= http://localhost/bp5am/ch11/confirm.php . ?id= $msgid ; 352 Chapter 11
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply