1 on 1 web hosting - Now you need to retrieve the user s e-mail
Saturday, May 31st, 2008Now you need to retrieve the user s e-mail address based on his or her user id, so you can send him or her an e-mail. This should also look familiar: $sql = SELECT * FROM ml_users . WHERE user_id= . $_GET[ u ] . ; ; $result = mysql_query($sql, $conn); $row = mysql_fetch_array($result); $firstname = $row[ firstname ]; $email = $row[ email ]; The body of this message is a little different. You are building the subject and body parameters for the mail() function and sending the mail to your user. Now you just need to send it on its way. $url = http:// . $_SERVER[ HTTP_HOST ] . dirname($_SERVER[ PHP_SELF ]) . /remove.php?u= . $_GET[ u ] . &ml= . $_GET[ ml ]; $subject = Mailing List Subscription Confirmed ; $body = Hello . $firstname . ,n . Thank you for subscribing to the . $listname . mailing list. Welcome!nn . If you did not subscribe, please accept our . apologies.n . You can remove this subscription immediately by . visiting the following URL:n . $url; $mailmsg = new SimpleMail(); $mailmsg->send($email,$subject,$body,$headers); Off your user goes, to the Thank You page: $redirect = thanks.php?u= . $_GET[ u ] . &ml= . $_GET[ ml ] . &t=s ; Finally, if action somehow is set to something other than Remove, Subscribe, or confirm, you will need to redirect the user somewhere else in this case, user.php. The final line handles the redirection: default: $redirect = user.php ; } } header( Location: . $redirect); The user_transact.php page is not terribly complicated. However, when you have a single page performing multiple tasks, you need to be careful that all situations are handled correctly. thanks.php Next let s look at the code in thanks.php. Most of it is familiar code that you have used elsewhere. You should have no problem breezing through this one. 509 Mailing Lists
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.