Connect to the (Web design careers) database: $conn = mysql_connect(SQL_HOST, SQL_USER,
Connect to the database: $conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS) or die( Could not connect to MySQL database. . mysql_error()); mysql_select_db(SQL_DB, $conn); Get user info based on the user id. If you find it, display the title Thank You, followed by the user s first name. Also grab the user s e-mail address. You ll use it later. if (isset($_GET[ u ])) { $uid = $_GET[ u ]; $sql = SELECT * FROM ml_users WHERE user_id = $uid ; $result = mysql_query($sql) or die( Invalid query: . mysql_error()); if (mysql_num_rows($result)) { $row = mysql_fetch_array($result); $msg =
Thank You, . $row[ firstname ] .
; $email = $row[ email ]; } else { die( No match for user id . $uid); } } Next, you get the listname, based on the mailing list id. If you find it, you build the message to include Thanks for subscribing. Once you get past this point, you know you have the user ID and mailing list ID. if (isset($_GET[ ml ])) { $ml_id = $_GET[ ml ]; $sql = SELECT * FROM ml_lists WHERE ml_id = . $ml_id . ; $result = mysql_query($sql) or die( Invalid query: . mysql_error()); if (mysql_num_rows($result)) { $row = mysql_fetch_array($result); $msg .= Thank you for subscribing to the . $row[ listname ] . mailing list.
; } else { die ( Could not find Mailing List $ml_id ); } } else { die ( Mailing List id missing. ); } Now all you have to do is determine the type of message you re displaying. if (!isset($_GET[ t ])) { die( Missing Type ); } It is crucial that the type be set. If not, stop processing this page. You don t know what to thank the user for. 510 Chapter 14
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.