Connecting Tech Pros Worldwide Help | Site Map

Insert into MySQL database using html form and php

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 11:30 AM
aseaman@echoes.net
Guest
 
Posts: n/a
Default Insert into MySQL database using html form and php

I am a big novice with MySQL and PHP. I need a script that enters
information from a html form into a MySQL database. Can anyone tell me
where I can find one that I can just replace the table and database
name? PLEASE I NEED IT ASAP!!!


  #2  
Old July 17th, 2005, 11:30 AM
RotterdamStudents
Guest
 
Posts: n/a
Default Re: Insert into MySQL database using html form and php

> I am a big novice with MySQL and PHP. I need a script that enters[color=blue]
> information from a html form into a MySQL database. Can anyone tell me
> where I can find one that I can just replace the table and database
> name? PLEASE I NEED IT ASAP!!!
>[/color]
form.htm
<html><head><title>Your title</title></head><body>
<form name="form1" method="post" action="input.php">
<input type=text name=001>
<input type=text name=002>
<input type=text name=003>
etc. etc.
Submit button
</form>
</body></html>
end of form.htm

input.php
<?php
$db = mysql_connect("server","username","password") or die("Cannot connect
to server");
mysql_select_db("databasename",$db) or die("Cannot find database");
$sql = mysql_query("INSERT INTO tablenam (field1, field2, field3, the names
of your fields in the table) VALUES('$001', '$002', '$003', 'the names of
the input types you want to insert in the fields in your database')") or die
(mysql_error());

?>
end of input.php

Martijn


  #3  
Old July 17th, 2005, 11:30 AM
Von Heler
Guest
 
Posts: n/a
Default Re: Insert into MySQL database using html form and php

Astonishing! Dogs scampered and hid under sideboards, hamsters stopped
turning in their wheels, and silence fell as RotterdamStudents paused,
put down his Happy Meal, and blurted:
[color=blue][color=green]
>> I am a big novice with MySQL and PHP. I need a script that enters
>> information from a html form into a MySQL database. Can anyone tell
>> me where I can find one that I can just replace the table and
>> database name? PLEASE I NEED IT ASAP!!!
>>[/color]
> form.htm
> <html><head><title>Your title</title></head><body>
> <form name="form1" method="post" action="input.php">
> <input type=text name=001>
> <input type=text name=002>
> <input type=text name=003>
> etc. etc.
> Submit button
> </form>
> </body></html>
> end of form.htm
>
> input.php
> <?php[/color]

You might want to put something like this here:

$001 = htmlspecialchars($_POST['001']);
$002 = htmlspecialchars($_POST['002']);
$003 = htmlspecialchars($_POST['003']);

[color=blue]
> $db = mysql_connect("server","username","password") or die("Cannot
> connect
> to server");
> mysql_select_db("databasename",$db) or die("Cannot find database");
> $sql = mysql_query("INSERT INTO tablenam (field1, field2, field3, the
> names of your fields in the table) VALUES('$001', '$002', '$003', 'the
> names of the input types you want to insert in the fields in your
> database')") or die (mysql_error());
>
> ?>
> end of input.php
>
> Martijn
>
>[/color]



--

You read too far. You should stop the moment you see Von Heler." Archangel
"long lunged + acting 'interesting' = Von Heler" Football Commentator




 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.