One of the first things that new users may want to do after signing up and logging in is to create a profile, which can be done via ExampleÂ 20-9, rnprofile.php. I think youâll find some interesting code here, such as routines to upload, resize, and sharpen images.
Letâs start by looking at the main HTML at the end of the code.
This is like the forms youâve just seen, but this time it has the
enctype='multipart/form-data'. This allows us
to send more than one type of data at a time, enabling the posting of an
image as well as some text. Thereâs also an
<input...> type of
file, which creates a browse button that a
user can press to select a file to be uploaded.
When the form is submitted, the code at the start of the program is executed. The first thing it does is ensure that a user is logged in before allowing program execution to proceed. Only then is the page heading displayed.
Adding the âAbout Meâ Text
'text' is checked to see whether
some text was posted to the program. If so, it is sanitized and all
long whitespace sequences (including returns and line feeds) are
replaced with a single space. This function incorporates a double
security check, ensuring that the user actually exists in the database
and that no attempted hacking can succeed before inserting this text
into the database, where it will become the userâs âabout meâ
If no text was posted, the database is queried to see whether any already exists ...