Inserting the Data Into the Database
June 23, 2000
At this stage we don't need to worry about loading data into the table,
we will do that next, using PHP and simple HTML forms. You can shut down
Telnet now and open up your favorite HTML editor. I would recommend
Homesite 4.0.
Now it was time for me to learn the
PHP basics,
which wasn't that difficult. I subscribed to the
PHP mailing list and took
a quick look through the
PHP manual. If you
can try to find somebody on ICQ that knows PHP, it sure does help
having instant support.
The idea here is to be able to insert all of the data into the database
via the internet using forms. I have created forms several times before
so that was no problem at all. I am assuming that you have used forms
before; if you have no idea how to create forms,
find a
tutorial
on the net and come back when your ready.
Create a page and call it add_data.php3, and then cut and paste the
following.
<form enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF ?>">
year<br>
<input type="Text" name="year" size="25">
<br>
make<br>
<input type="Text" name="make" size="25">
<br>
model<br>
<input type="Text" name="model" size="25">
<br>
price<br>
<input type="Text" name="price" size="25">
<br>
picture<br>
<input type="File" name="picture" size="25">
<br><br>
<input type="submit" name="submit" value="Upload">
</form>
First of all we need to add a little PHP in the action attribute, this
is used to display all of the data once the submit button is pressed.
action="<?php echo $PHP_SELF ?>"
The name attribute within the input element will be used to pass the
information to PHP, these names should be the same as the columns in
the database.
Its Time to Connect to the Server
PHP, MySQL and Images
Making It All Work
|