Creating Databases for Web Applications - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Creating Databases for Web Applications

Description:

Creating Databases for Web Applications. Consumer tracking discussion ... Can open for reading or writing (append-adding records) fclose -- ends connection. ... – PowerPoint PPT presentation

Number of Views:133
Avg rating:3.0/5.0
Slides: 16
Provided by: jeanin72
Category:

less

Transcript and Presenter's Notes

Title: Creating Databases for Web Applications


1
Creating Databases for Web Applications
  • Consumer tracking discussion
  • php and files
  • Homework Complete work for presentations on
    enhanced basic projects

2
Consumer tracking
  • Privacy
  • Something beyond privacy?
  • Making a commodity of my behavior
  • Finding ways to market to me
  • Finding ways to market to others
  • ?

3
Tools
  • http//www.privacychoice.org/
  • Do you want to use this?
  • not clear of use in different browsers.

4
Cookies and
  • SharedObjects
  • learn about this from a team project?
  • Downloaded images may also contain information

5
When to use a file as opposed to a database?
  • Data too simple or too complex
  • Scores
  • File created for multiple purposes
  • Use file in conjunction with database
  • Upload image files
  • Semi-dynamic page
  • ?

6
php file functions
  • fopen -- finds and makes connection. Can open
    for reading or writing (append-adding records)
  • fclose -- ends connection. Other programs can
    connect to the file
  • fread -- read in specified amount of data
  • fwrite -- write to file
  • copy -- make a copy
  • unlink DELETES file
  • ALSO files for uploading a file

7
Uploading files
  • This is giving a user facility to open files
    through html and php scripts.
  • Considered risky.
  • Possible to put in checking.
  • The php installation must permit it.
  • to the phpinfo test
  • Specific input type in form
  • I created a directory with full permissions for
    writing / uploading new files.
  • EXTRA credit opportunity report on permissions!

8
fileupload1.html
  • lthtmlgt
  • ltheadgtlttitlegtGet file name lt/titlegtlt/headgtltbodygt
  • ltform action"fileupload2.php" method"post"
  • enctype"multipart/form-data"gt
  • ltlabel for"file"gtFilenamelt/labelgt
  • ltinput type"file" name"file" id"file" /gt
  • ltbr /gt
  • ltinput type"submit" name"submit" value"Submit"
    /gt
  • lt/formgt
  • lt/bodygt lt/htmlgt

9
fileupload2.php
  • lt?php
  • if (((_FILES"file""type" "image/gif")
  • (_FILES"file""type" "image/jpeg")
  • (_FILES"file""type" "image/pjpeg"))
  • (_FILES"file""size" lt 200000))
  • if (_FILES"file""error" gt 0)
  • echo "Return Code " . _FILES"file""error"
    . "ltbr /gt"
  • else

10
fileupload2.php, cont.
  • echo "Upload " . _FILES"file""name" .
    "ltbr /gt"
  • echo "Type " . _FILES"file""type" .
    "ltbr /gt"
  • echo "Size " . (_FILES"file""size" /
    1024) . " Kbltbr /gt"
  • echo "Temp file " . _FILES"file""tmp_name
    " . "ltbr /gt"
  • if (file_exists(_FILES"file""name"))
  • echo _FILES"file""name" . " already
    exists. "
  • else
  • target "uploads/"
  • target . _FILES"file""name"
  • move_uploaded_file
  • (_FILES"file""tmp_name",target)
  • echo "Stored as " . target

11
fileupload2.php
  • else
  • echo "Invalid file"
  • ?gt

12
Example
  • .db/fileuploadex/fileupload1.html
  • Stores files in subfolder uploads

13
Comments
  • You don't need to put in all the messages!
  • My code only allows images. Files must be less
    than 2M. You may have use to upload other things.
  • Process is not instant!
  • I thought it wasn't working, because it didn't
    show up immediately using FileZilla.

14
Class time
  • Complete work to demonstrate and present enhanced
    basic projects

15
Homework
  • Complete presentations
  • Start to plan your own projects
  • Teams are acceptable, but from more, more is
    expected
  • HTML JavaScript or Flash ActionScript
  • Forms, data entry, data validation, more than 1
    table
  • Proposal posting, Presentation of designs
    (diagrams), final presentation
Write a Comment
User Comments (0)
About PowerShow.com