Script School Classroom

School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store | FORUMS
Script School - MySQL 101 - Week #3
Review and Preview Well, so far we have examined
what Relational Databases are and what they can do. We've seen how to
design a database for efficiency that meets our needs. We've discussed
the various relationships within databases. We have set up our Tables
for the project we are creating in this course, to create a browser based application
to keep track of our Websites and Sponsors. This week we will concentrate
on how to put data into the database. We will build various HTML forms
that will interact with the MySQL database through the server side scripting
language, PHP. You may wish to review or take the
various PHP courses offered by Script School. We will see how to check incoming
data for errors and how to report those errors back to the user, and make sure
data is properly formatted for insertion into the database.
HTML Forms We'll use HTML forms to post the
data to our PHP script for insertion into MySQL. We'll need a form field
for each field in our database - except the automatic fields.
You'll notice there are no ID or Date fields in the forms. This week we'll create
our forms for the Websites and Sponsors Tables, and see how to insert the data
into our database. Next week, after we see how to pull or select data from our
database, and we'll see how to populate drop down lists 'on-the-fly' which will
be used to add records to our Website_Sponsor Table, which as You'll recall,
is used to relate the Websites and Sponsors to each other.
Note: Visual Forms are shown as examples ONLY - Do NOT copy them - use full
code below.
|
HTML and PHP to create Websites Form
<!-- Note: using PHP $_SERVER['PHP_SELF'] as action value, to go back to, and process, this script (page) again with posted values --> <form name="WebsitesForm" method="post" action=" <?php echo ''.$_SERVER['PHP_SELF'].''; ?> "> <table width="632" border="1" align="center" cellpadding="2" cellspacing="1" bordercolor="#0000FF" bgcolor="#99CCFF" rules="rows"> <caption> <strong>Websites Form</strong> </caption> <tr> <td width="135" align="right">Website Name</td> <td width="5" align="right"> </td> <td width="480" align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <input name="w_name" type="text" id="w_name" value="<?php echo $_SESSION['w_name']; ?>" size="58" maxlength="255"> <!-- Note: Use PHP function to report error, if found --> <?php show_error('w_name_err'); ?> </td> </tr> <tr> <td align="right">Website URL</td> <td align="right"> </td> <td align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <input name="w_url" type="text" id="w_url" value="<?php echo $_SESSION['w_url']; ?>" size="58" maxlength="255"> <!-- Note: Use PHP function to report error, if found --> <?php show_error('w_url_err'); ?> </td> </tr> <tr> <td align="right">Description</td> <td align="right"> </td> <td align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <textarea name="w_desc" cols="50" rows="5" wrap="HARD" id="w_desc"><?php echo $_SESSION['w_desc']; ?></textarea> </td> </tr> <tr> <td align="right">Status</td> <td align="right"> </td> <td align="left"> <select name="w_status" id="w_status"> <!-- Note: PHP function to show selected value if error found --> <option value="Pending" <?php show_selected('w_status','Pending'); ?> >Pending</option> <option value="Active" <?php show_selected('w_status','Active'); ?> >Active</option> <option value="Inactive" <?php show_selected('w_status','Inactive'); ?> >Inactive</option> <option value="Defunct" <?php show_selected('w_status','Defunct'); ?> >Defunct</option> </select> </td> </tr> <tr> <td colspan="3" align="center"> <input name="Reset-Websites" type="reset" id="Reset-Websites" value="Clear Form"> <!-- Note: button name="Submit_Websites" used to check for submission --> <input type="submit" name="Submit_Websites" value="Submit Website"> </td> </tr> </table> </form>
|
Of course, You have noticed our custom PHP functions show_error(),
associated with our required fields - those that don't allow NULL values in
the database - and show_selected(), as well as the $_SESSION variables used
in the values of various input elements. Let's see the HTML and PHP for
the Sponsors Table before we discuss data parsing, security and error handling
using $_SESSIONS.
Note: Visual Forms are shown as examples ONLY - Do NOT copy them - use full
code below.
|
HTML and PHP to create Sponsors Form
<!-- Note: using PHP $_SERVER['PHP_SELF'] as action value, to go back to, and process, this script (page) again with posted values --> <form name="SponsorsForm" method="post"
action="<?php echo ''.$_SERVER['PHP_SELF'].''; ?>"> <table width="632" border="1" align="center" cellpadding="2"
cellspacing="1" bordercolor="#0000FF" bgcolor="#99CCFF" rules="rows"> <caption> <strong>Sponsors Form</strong> </caption> <tr> <td width="135" align="right">Sponsor Name</td> <td width="5" align="right"> </td> <td width="480" align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <input name="s_name" type="text" id="s_name" value="<?php echo $_SESSION['s_name']; ?>" size="58" maxlength="255"> <!-- Note: Use PHP function to report error, if found --> <?php show_error('s_name_err'); ?> </td> </tr> <tr> <td align="right">Sponsor URL</td> <td align="right"> </td> <td align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <input name="s_url" type="text" id="w_url" value="<?php echo $_SESSION['s_url']; ?>" size="58" maxlength="255"> <!-- Note: Use PHP function to report error, if found --> <?php show_error('s_url_err'); ?> </td> </tr> <tr> <td align="right">Statistics URL</td> <td align="right"> </td> <td align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <input name="s_staturl" type="text" id="s_staturl" value="<?php echo $_SESSION['s_staturl']; ?>" size="58" maxlength="255"> </td> </tr> <tr> <td align="right">Sponsor Email</td> <td align="right"> </td> <td align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <input name="s_email" type="text" id="s_email" value="<?php echo $_SESSION['s_email']; ?>" size="58" maxlength="255"> </td> </tr> <tr> <td align="right">User Name</td> <td align="right"> </td> <td align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <input name="s_uname" type="text" id="s_uname" value="<?php echo $_SESSION['s_uname']; ?>" size="58" maxlength="255"> </td> </tr> <tr> <td align="right">Password</td> <td align="right"> </td> <td align="left"> <!-- Note: Value is PHP Session Variable, possibly blank --> <!-- Note: This is insecure! Critical use requires password again! --> <input name="s_pass" type="password" id="s_pass" value="<?php echo $_SESSION['s_pass']; ?>" size="58" maxlength="255"> </td> </tr> <tr> <td align="right">Status</td> <td align="right"> </td> <td align="left"> <select name="select" id="select"> <!-- Note: PHP function to show selected value if error found --> <option value="Pending" <?php show_selected('s_status','Pending'); ?> >Pending</option> <option value="Active" <?php show_selected('s_status','Active'); ?> >Active</option> <option value="Inactive" <?php show_selected('s_status','Inactive'); ?> >Inactive</option> <option value="Defunct" <?php show_selected('s_status','Defunct'); ?> >Defunct</option> </select> </td> </tr> <tr> <td colspan="3" align="center"> <input name="Reset-Sponsors" type="reset" id="Reset-Sponsors" value="Clear Form"> <!-- Note: button name="Submit_Sponsors" used to check for submission --> <input type="submit" name="Submit_Sponsors" value="Submit Sponsor"> </td> </tr> </table> </form>
|
Data Parsing and Security Although the
application we are building in this course will most likely be used within a
single computer or private network, for learning purposes we will approach it
as though it will be web based. Incoming data must be checked to make
sure that it actually exists in all of the required places, and is of the correct
type. We need to provide error messages to the user when the data is 'wrong'.
Webmasters also have the responsibility of paying attention to security concerns.
We must 'clean' incoming data to stop dangerous code that could do harm to the
server or our applications, or compromise the information in our database.
When PHP's 'Magic Quotes' are on (default is ON) - data from
HTML pages and forms (and cookies) have all ' (single-quote), " (double
quote), \ (backslash) and NUL's escaped with a backslash: \
We usually have to strip those slashes, then add new slashes with mysql_escape_string()
for ALL of the characters that present problems when inserting data into a MySQL
database.
PHP has several commonly used functions for these purposes:
- trim()
removes blank 'whitespace' from the beginning and end of strings
" " (ordinary space), \t (tab), \n (newline), \r (carriage return),
\0 (NUL-byte), \x0B (vertical tab)
- substr()
reduces strings to a maximum number of characters
- empty()
returns TRUE if variable contains: "", 0, "0", NULL, or
FALSE
Often used with the ! NOT command: !empty()
- isset()
returns TRUE if variable has been 'set' or given any value other than NULL
- is_numeric()
checks if a variable contains a number or a string which can be converted
into a number
- is_string()
checks if a variable contains a string
- stripslashes()
removes one backslash directly before each character where present
- addslashes()
'escapes', or prefixes backslashes to, the following characters: NUL, ', "
and \
- mysql_escape_string()
prepares a string for use in a mysql_query. It escapes the following characters:
NUL (\x00), \n, \r, \, ', " and \x1a
- strip_tags()
removes PHP and HTML tags from a string (See manual reference for weaknesses
and alternatives)
- htmlspecialchars()
encodes some special characters into harmless HTML entities
&, <, >, " (double quote) when parameter ENT_NOQUOTES is not
set, ' (single quote) when parameter ENT_QUOTES is set
- htmlentities()
converts ALL applicable characters to HTML entities, same parameters as htmlspecialchars()
for quote control
- html_entity_decode()
decodes strings encoded with htmlentites (PHP 4 >= 4.3.0)
- get_magic_quotes_gpc()
indicates if magic quotes are on by PHP initialization settings, default
is ON (gpc = get, post, cookie)
- set_magic_quotes_runtime()
switches magic quotes during runtime, does not affect ini settings
- escapeshellcmd()
escapes ALL special purpose and command characters with backslashes - prevents
server ('shell') commands from passing through. Can be excessive for typical
webpage and database purposes.
You should be extremely careful with:
Keep in mind that Your scripts are not the only factor to consider
in securing Your systems. Other general considerations include: user authentication,
data transmission, physical access and protection, and data back up.
PHP for Form and Error Handling and Entering Data into the Database
When the data from HTML forms sent through the post method is received by PHP,
the values are contained in the $_POST array, which is created automatically
by PHP. The complete script for this week is shown below, please study
the comments. PHP functions that we have not used before are linked to
the PHP manual pages.
We create two functions: show_error() to write a line of HTML when required
fields are empty, and show_selected() which will show
the previously selected value in the drop down list if required fields are empty.
show_error() takes a $field variable
(argument) such as: 'w_name_err' which relates to a $_SESSION variable of the
same 'key'. In the 'logic' section, the $_SESSION
variable holding the error is given a value of 1 if the required form field
is empty. SESSION variables retain their values from page to page, during the
same browser 'session'. The logic section also creates a general error
flag, $err. If $err is 1 (for TRUE), then we use a header
to redirect back into this same script again, to show the errors (fields which
are empty that are required for our database). We pass the session_id
attached to the URL as SID
- an automatic value provided by PHP for this purpose - and use it as the session_id
, if(isset($_GET["PHPSESSID"]))
{Line 1 of the script}. We could have used a cookie to hold the SESSION
ID instead.
show_selected works in a similar manner
to show_error, writing 'selected' in the previously selected option when returning
to the script to show empty field errors. We also use other SESSION variables
to hold previously entered user values to recreate the form during error reporting.
If these are blank, then the form will simply show blank fields, ready for the
user to fill in.
Logic Sequence We use the name value
of the forms submit button to see which form was submitted and handle the data
accordingly. The forms also redirect back into this same script, through
their 'action' value, to show the success or failure of the database INSERT.
Inserting Data The SQL syntax for INSERT
queries is fairly straightforward:
INSERT INTO `tablename`
SET fieldname = value,
fieldname = value;
The backticks ` `around the tablename can also be
applied to the fieldnames,
they are used to allow names that might conflict with reserved terms in
MySQL and
are a good general practice. One other note is that whether the case of
names is recognized as in websites vs. Websites, depends on the operating system
of Your server, just like directory names in the file system. Windows
is case insensitive.
Perhaps one slightly tricky thing to point out is that
You have to use both single ' and double "
quotes around any PHP variables holding values You wish to INSERT: SET
w_name = '".$_POST['w_name']."'
The outside single quotes ' are present because we can only
put values into queries as strings - the field types of MySQL will determine
the actual format in the database. The double quotes are there to escape
from PHP variable notation since we start out using double quotes to assign
the query to a PHP variable, as in: $query = "INSERT ...
"; . Finally we use PHP's concatenation operator
the . to join our variable value to the string we are creating.
See the link to the MySQL manual on INSERT
for an alternate basic syntax which is 'mainstream' SQL syntax, more details
and advanced concepts.
Another interesting aspect of this script is the use
of one of the MySQL
Date and Time Functions NOW()
to insert the date into the Sponsor Table s_date Field. Note how the MySQL function
call is not quoted or escaped in any way, it is simply part of the SQL query
string held in the PHP variable: $query_insert_sponsor.
This is an example of how to use any of the many native MySQL functions through
a PHP script.
|
Complete Script for this Week
<?php // Using Sessions: // Check if Session was started by an error redirect: if(isset($_GET["PHPSESSID"])){
// Assign it for current Session: $Sess_ID = $_GET["PHPSESSID"]; session_id("$Sess_ID"); } // Start Session to show form inputs on error: session_start();
// Create
a function to show errors:
function show_error($field){
if($_SESSION[$field]){
echo
'<br><font color="#FF0000" size="2" face="Arial"><br>
<b>ERROR: Blank or only contains disallowed tag(s).</b></font>';
}
}
// Create
a function to show previously selected status on error:
function show_selected($field, $status){
if($status == $_SESSION[$field]){
echo
'selected';
}else if($status == 'Pending'){
echo
'selected';
}
}
// Logic sequence:
// If data was submitted from a form:
if(isset($_POST['Submit_Websites'])
|| isset($_POST['Submit_Sponsors'])){
// Note: magic quotes does addslashes()
compare to mysql_escape_string()
in text above
// determine if magic quotes are on:
if(get_magic_quotes_gpc()){
// we'll use mysql_escape_string()
for database insert
// go through $_POST
and stripslashes:
foreach($_POST
as $key => $value){
// Note:
Changing the values in the $_POST array:
$_POST[$key]
= stripslashes($value);
}
}
//
Store values in session variables
//
to re-write form if there is an error:
foreach($_POST
as $key => $value){
$_SESSION[$key]
= $value;
}
//
Remove tags and whitespaces:
foreach($_POST
as $key => $value){
//
Note: Changing the values in the $_POST array:
$_POST[$key]
= strip_tags(trim($value));
}
//
Check for errors,
//
(see if required fields are empty)
//
since only one form can be submitted at a time,
//
check each individually:
if(isset($_POST['Submit_Websites'])){
if(empty($_POST['w_name'])){
//
Specific error flag in session variable:
$_SESSION['w_name_err']
= 1;
//
General error flag:
$err = 1;
}
if(empty($_POST['w_url'])){
$_SESSION['w_url_err']
= 1;
$err = 1;
}
}
if(isset($_POST['Submit_Sponsors'])){
if(empty($_POST['s_name'])){
$_SESSION['s_name_err']
= 1;
$err = 1;
}
if(empty($_POST['s_url'])){
$_SESSION['s_url_err']
= 1;
$err = 1;
}
}
//
Check general error flag:
if($err){
//
If there is an error then redirect back to form page to show errors:
header("Location:".$_SERVER['PHP_SELF']."?".SID);
} else {//
no errors
// Unset all of the session variables.
$_SESSION = array();
// Destroy the session.
session_destroy();
//
Get data ready for insertion into database:
foreach($_POST
as $key => $value) {
//
Note: Changing the values in the $_POST array:
$_POST[$key]
= mysql_escape_string(htmlentities($value));
}
//
Enter data into database sequence
//
connect to mysql
$db
= mysql_connect('host','username','password')
or
die('Could not connect to MySQL Server.');
//
connect to database
//
Note: @ suppresses regular error reporting
@mysql_select_db('ssMySQLclass',$db)
or
die('Could not connect to database.');
//
See if submit button named 'Submit_Websites' was posted:
if(isset($_POST['Submit_Websites'])){
//
Write Insert Query to a Variable:
$query_insert_website
= "INSERT
INTO `Websites`
SET w_name
= '".$_POST['w_name']."',
w_url = '".$_POST['w_url']."',
w_desc = '".$_POST['w_desc']."',
w_status =
'".$_POST['w_status']."'
";
//
Do Websites Table Data Insert, check if Row added:
if((@
mysql_query($query_insert_website,
$db)) && @ mysql_affected_rows()
== 1){
//
Report success:
echo
'<h3>Website Data Inserted into Websites Table.</h3>';
} else { //
Report problem:
echo
'<h3>Could not add data to Websites Table.</h3>';
}//end query
}//end isset Websites
// See if submit button
named 'Submit_Sponsors' was posted:
if(isset($_POST['Submit_Sponsors'])){
// Write
Insert Query to a Variable:
$query_insert_sponsor = "INSERT
INTO `Sponsors`
SET s_name = '".$_POST['s_name']."',
s_url = '".$_POST['s_url']."',
s_staturl = '".$_POST['s_staturl']."',
s_email = '".$_POST['s_email']."',
s_uname = '".$_POST['s_uname']."',
s_pass = '".$_POST['s_pass']."',
s_status = '".$_POST['s_status']."',
s_date = NOW()
";
// Do Sponsors Table
Data Insert, check if Row added:
if((@ mysql_query($query_insert_sponsor,
$db)) && @ mysql_affected_rows()
== 1){
//
Report success:
echo
'<h3>Sponsor Data Inserted into Sponsors Table.</h3>';
} else { //
Report problem:
echo
'<h3>Could not add data to Sponsors Table.</h3>';
} //end query
} //end isset Sponsors
} //end if($err){}else{}
} // end if submit form data
?>
<!-- Note: the rest of this is here
just to show how everything goes together in a single .php page,
it is not indented, see the form examples above for clearer formatting.
-->
<html>
<head>
<title>Script School - MySql 001 - Week 3 - Script</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<!-- SHOW FORMS -->
<!-- Note: using PHP $_SERVER['PHP_SELF'] as action value,
to go back to, and process, this script (page) again with posted values
-->
<form name="WebsitesForm" method="post"
action=" <?php echo ''.$_SERVER['PHP_SELF'].'';
?> ">
<table width="632" border="1" align="center"
cellpadding="2" cellspacing="1" bordercolor="#0000FF"
bgcolor="#99CCFF" rules="rows">
<caption>
<strong>Websites Form</strong>
</caption>
<tr>
<td width="135" align="right"> Website
Name</td>
<td width="5" align="right"> </td>
<td width="480" align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<input name="w_name" type="text" id="w_name"
value="<?php echo $_SESSION['w_name'];
?>" size="58" maxlength="255">
<!-- Note: Use PHP function to report error,
if found -->
<?php show_error('w_name_err'); ?>
</td>
</tr>
<tr>
<td align="right">Website URL</td>
<td align="right"> </td>
<td align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<input name="w_url" type="text" id="w_url"
value="<?php echo $_SESSION['w_url'];
?>" size="58" maxlength="255">
<!-- Note: Use PHP function to report error,
if found -->
<?php show_error('w_url_err'); ?>
</td>
</tr>
<tr>
<td align="right">Description</td>
<td align="right"> </td>
<td align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<textarea name="w_desc" cols="50" rows="5"
wrap="HARD"
id="w_desc"><?php echo $_SESSION['w_desc'];
?></textarea>
</td>
</tr>
<tr>
<td align="right">Status</td>
<td align="right"> </td>
<td align="left">
<select name="w_status" id="w_status">
<!-- Note: PHP function to show selected value
if error found -->
<option value="Pending" <?php
show_selected('w_status','Pending'); ?>
>Pending</option>
<option value="Active" <?php
show_selected('w_status','Active'); ?>
>Active</option>
<option value="Inactive" <?php
show_selected('w_status','Inactive'); ?>
>Inactive</option>
<option value="Defunct" <?php
show_selected('w_status','Defunct'); ?>
>Defunct</option>
</select>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<input name="Reset-Websites" type="reset" id="Reset-Websites"
value="Clear Form">
<!-- Note: input name="Submit_Websites"
used to check for submission -->
<input type="submit" name="Submit_Websites" value="Submit
Website">
</td>
</tr>
</table>
</form>
<!-- Note: using PHP $_SERVER['PHP_SELF']
as action value,
to go back to, and process, this script (page) again with posted values
-->
<form name="SponsorsForm" method="post" action="<?php
echo ''.$_SERVER['PHP_SELF'].''; ?>">
<table width="632" border="1" align="center"
cellpadding="2" cellspacing="1" bordercolor="#0000FF"
bgcolor="#99CCFF" rules="rows">
<caption>
<strong>Sponsors Form</strong>
</caption>
<tr>
<td width="135" align="right">Sponsor Name</td>
<td width="5" align="right"> </td>
<td width="480" align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<input name="s_name" type="text" id="s_name"
value="<?php echo $_SESSION['s_name'];
?>" size="58" maxlength="255">
<!-- Note: Use PHP function to report error,
if found -->
<?php show_error('s_name_err'); ?>
</td>
</tr>
<tr>
<td align="right">Sponsor URL</td>
<td align="right"> </td>
<td align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<input name="s_url" type="text" id="w_url"
value="<?php echo $_SESSION['s_url'];
?>" size="58" maxlength="255">
<!-- Note: Use PHP function to report error,
if found -->
<?php show_error('s_url_err'); ?>
</td>
</tr>
<tr>
<td align="right">Statistics URL</td>
<td align="right"> </td>
<td align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<input name="s_staturl" type="text" id="s_staturl"
value="<?php echo $_SESSION['s_staturl'];
?>" size="58" maxlength="255">
</td>
</tr>
<tr>
<td align="right">Sponsor Email</td>
<td align="right"> </td>
<td align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<input name="s_email" type="text" id="s_email"
value="<?php echo $_SESSION['s_email'];
?>" size="58" maxlength="255">
</td>
</tr>
<tr>
<td align="right">User Name</td>
<td align="right"> </td>
<td align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<input name="s_uname" type="text" id="s_uname"
value="<?php echo $_SESSION['s_uname'];
?>" size="58" maxlength="255">
</td>
</tr>
<tr>
<td align="right">Password</td>
<td align="right"> </td>
<td align="left">
<!-- Note: Value is PHP Session Variable, possibly
blank -->
<!-- Note: This is insecure! Critical use requires password again!
-->
<input name="s_pass" type="password" id="s_pass"
value="<?php echo $_SESSION['s_pass'];
?>" size="58" maxlength="255">
</td>
</tr>
<tr>
<td align="right">Status</td>
<td align="right"> </td>
<td align="left">
<select name="select" id="select">
<!-- Note: PHP function to show selected value
if error found -->
<option value="Pending" <?php
show_selected('s_status','Pending'); ?>
>Pending</option>
<option value="Active" <?php
show_selected('s_status','Active'); ?>
>Active</option>
<option value="Inactive" <?php
show_selected('s_status','Inactive'); ?>
>Inactive</option>
<option value="Defunct" <?php
show_selected('s_status','Defunct'); ?>
>Defunct</option>
</select>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<input name="Reset-Sponsors" type="reset" id="Reset-Sponsors"
value="Clear Form">
<!-- Note: button name="Submit_Sponsors"
used to check for submission -->
<input type="submit" name="Submit_Sponsors" value="Submit
Sponsor">
</td>
</tr>
</table>
</form>
</body>
|
If You have any questions, please use the Script
School Forum, the LIVE
CHAT Tuesday workshops, or Chat
or call during the LIVE
Radio Show on Fridays.
Next Week We'll see how to SELECT data
from our database to populate drop down lists with values.
Week #3 Assignments
Basic Assignment: Create forms for the
Websites and Sponsors database tables, and the PHP script to prepare
and INSERT the data into their respective tables in the database.
Advanced Assignment: Do the basic assignment
and add more advanced error handling, such as checking the length of passwords,
determining if a quantity, age, or date field is a number and compare it to
a qualifying point, or perhaps researching and using ways to ensure that email
addresses are valid. Provide 'customized' error messages for each field
- or perhaps customized animated images and/or sounds to indicate different
errors.
Submit Your assignments to the Script
School Forum for comments and 'credit'
| Need help with your assignment or have questions
about the first week's course?
|
School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store
Advertising
| Link To Us | Privacy
Copyright 2000-2002 Script School Productions / KMR
Enterprises
No part of this website may be reproduced, copied and/or distributed
in any medium
without express written permission