Web site traffic - $sql = CREATE DATABASE postcard ; $success = mysql_query($sql,
$sql = CREATE DATABASE postcard ; $success = mysql_query($sql, $conn) or die(mysql_error()); echo Database created. . . ; Now that the database is created, the script then selects that database. mysql_select_db( postcard , $conn); Next, you create the images table in the database, containing three columns. As before, if the creation is successful, the script prints images table created to the screen and moves on. $sql = CREATE TABLE images (id int NOT NULL primary key auto_increment, img_url VARCHAR(255) NOT NULL, img_desc text ) ; $success = mysql_query($sql, $conn) or die(mysql_error()); echo images table created. . . ; Next, you need to create two arrays of values to place in the images table. You need to know the location of the postcards entered previously in step 1 and their descriptions. Each URL corresponds to a description in the other array. $imgURL = array( punyearth.gif , grebnok.gif , sympathy.gif , congrats.gif ); $imgDESC = array( Wish you were here! , See you soon! , Our Sympathies , Congratulations! ); Next, the script loops through the arrays, pulling the location and description text and inserting them into the images table. If there are no errors, the script prints Data entered to the screen. for ($i=0; $i<4; $i++) { $sql = INSERT INTO images ( images.img_url , images.img_desc ) VALUES ( $imagepath$imgURL[$i] , $imgDESC[$i] ) ; $success = mysql_query($sql, $conn) or die(mysql_error()); } Echo Data entered. . . ; When you run this PHP script, if anything goes wrong, make sure you delete the postcard database before running it again. Otherwise, you will get an error (database exists) and the script will stop executing. You ll include the code to view and use the images in the next section. Getting Confirmation So far, you have a pretty cool postcard application. Any user can send a postcard to whomever he or she wants, and PHP takes care of mailing it. Unfortunately, there is still a small problem with the application. As the application stands right now, it is quite easy for the user to use any e-mail address in the From field. This is a bad thing because nasty e-mails can be sent on someone else s behalf, and you don t want that, do you? To prevent such maliciousness, you must first send a confirmation e-mail to the From 339 Sending E-mail
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.