Presentation is loading. Please wait.

Presentation is loading. Please wait.

Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database.

Similar presentations


Presentation on theme: "Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database."— Presentation transcript:

1 Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database. Call it “postcard.” If it is successful, print “Database created” to the screen and move on. $sql = “CREATE DATABASE postcard”; $success = mysql_query($sql, $conn) or die(mysql_error()); Echo “Database created. . .”; <?php mysql_select_db(“yourdatabase”, $conn); ?> Save this file as conn_comic.php in the includes/ folder. Now that you’ve created the database, select that database. mysql_select_db(“postcard”, $conn);

2 Crating Images Table require(“./includes/conn_comic.php”);
Create the images table in the database, containing three columns. $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. . .” Now create two arrays of values to place in the images table. $imgURL = array(‘/postcards/punyearth.gif’, ‘/postcards/grebnok.gif’, ‘/postcards/sympathy.gif’, ‘/postcards/congrats.gif’); $imgDESC = array(‘Wish you were here!’, ‘See you soon!’, ‘Our Sympathies’, ‘Congratulations!’);

3 Accessing from Database
Loop through the arrays, pulling the location and description text and inserting them into the images table. for ($i=0; $i<4; $i++) { $sql = “INSERT INTO images ( images.img_url , images.img_desc ) VALUES ( ‘$imgURL[$i]’, $imgDESC[$i]’)”; $success = mysql_query($sql, $conn) or die(mysql_error()); } Echo “Data entered. . .”; When running 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 it will stop executing.

4 Getting Confirmation To prevent maliciousness, you must first send a confirmation to the “From” address. Once you get the confirmation, you know the user entered a good address, and you can go ahead and send the In order to confirm an address, the postcard information needs to be temporarily stored in a table, to be retrieved later on, once confirmation has been established:

5

6 Postcard.php

7 Enter the appropriate data;remember to put in your valid e-mail address in the From: email field.
In the Choose a Postcard field, select a postcard from the drop-down list, enter a message, and click the Send button. A screen similar to the one shown in Figure 10-7 loads.

8 Pc-sendconf.php

9

10 Click the link at the bottom of the e-mail to confirm that you want to send the postcard.
Once the user clicks the confirmation link, the postcard is sent to the intended recipient. Open the account this postcard was sent to

11

12 Here is the code of this validation in PHP. if(isset($todo) and $todo=="test"){ if $ )){ echo "<center>Invalid </center>"; }else{ echo "<center>Valid </center>";} }


Download ppt "Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database."

Similar presentations


Ads by Google