Forms Processing
Jacob Hurley
jacobh at aos5.com
Thu May 8 20:46:16 CDT 2003
This thread is getting a bit disturbing, so i will just reply to the original with some examples to
get you going.
you can setup your mysql database and tables manually in mysql:
#mysql -p
create database buildb0x;
use buildb0x;
create table tagboard (id tinyint (4) not null auto_increment,
username varchar (32) not null, msg varchar (50), http varchar (32) ,
primary key (id, username))
;
show tables;
+--------------------+
| Tables_in_buildb0x |
+--------------------+
| tagboard |
| users |
+--------------------+
2 rows in set (0.00 sec)
or if you create all of your tables in a file such as my_tables.sql
#mysql -p -D my_database < my_tables.sql
as for the discussion, PHP is a great 'scripting language'. here are some examples of how to
interact with you mysql ('sniipets' taken from an old project i was working on):
<? session_start(); ?>
<html><body>
<?
$db = mysql_pconnect( "localhost", "username", "p4ssw0rd");
if (!$db)
{
echo "err0r: can't connect to the database dumbass!";
exit;
}
mysql_select_db("buildb0x");
$query = "select * from url order by urlid desc";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$i = 1;
while ($row = mysql_fetch_array($result) and $i < 11)//a loop
{
?>
<tr><td width="75%" align="left"><font size=-1 color=black>
<?
echo $i;
echo ".<a href=http://".$row["url"]."> ";
echo $row["url"]."</a><br>";
echo $row["type"]."<font color=blue> | </font><font size=-1 color=black>";
echo $row["description"];
?>
<hr>
</td><td width="25%" valign="top">
<?
echo "</font><font size=-1 color=gray> | </font><font size=-2 color=black>".$row["posted_by"];
echo "<br></font><font color=gray size=-1> | </font><font size=-2
color=black>".$row["date"]."</font>";
$i = $i + 1;
}
?>
you can make your $query whatever you want, so if you need to INSERT into the db (more snippets):
$query = "insert into mp3 values
('NULL', '".$username."', '".$datetime."', '/mp3/".$cleanname."',
'".$userfile_name."',
'".$type."', '0', '0', '0', 'NULL' )";
$result = mysql_query($query);
if(!$result)
{
echo 'cannot run query.';
}
$query = "update users set uploads = '$uploads' where username =
'$username'";
$result = mysql_query($query);
if(!$result)
{
echo "cannot run query.";
exit;
}
these are just some examples (and pretty basic), if you read into it some you will see other things
that need to be before you insert data into the database such as: add_slashes();
i hope this helps out some and i and somewhat curious to see your project, good luck
jacob
-----Original Message-----
From: Jason Clinton [mailto:me at jasonclinton.com]
Sent: Wednesday, May 07, 2003 1:40 PM
To: kclug at kclug.org
Subject: Forms Processing
A bit OT but here it goes anyway:
Do any of you have a recommendation for a CGI Forms processing script that can store to database?
That you've used in the past? I need to implement a quick HTML form and dump the output to a MySQL
table.
--
Jason Clinton
I don't believe in witty sigs.
More information about the Kclug
mailing list