473,796 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!!!

Jul 17 '05 #1
2 12222
> 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!!!

form.htm
<html><head><ti tle>Your title</title></head><body>
<form name="form1" method="post" action="input.p hp">
<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","userna me","password ") or die("Cannot connect
to server");
mysql_select_db ("databasename" ,$db) or die("Cannot find database");
$sql = mysql_query("IN SERT 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
Jul 17 '05 #2
Astonishing! Dogs scampered and hid under sideboards, hamsters stopped
turning in their wheels, and silence fell as RotterdamStuden ts paused,
put down his Happy Meal, and blurted:
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!!!
form.htm
<html><head><ti tle>Your title</title></head><body>
<form name="form1" method="post" action="input.p hp">
<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


You might want to put something like this here:

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

$db = mysql_connect(" server","userna me","password ") or die("Cannot
connect
to server");
mysql_select_db ("databasename" ,$db) or die("Cannot find database");
$sql = mysql_query("IN SERT 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


--

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


Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7400
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
1
5427
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. And the line it shows in red is cmd.ExecuteNonQuery()
15
4646
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
5
2522
by: Bonzol | last post by:
Hello, PHP n00b here. Using SQL just working off some examples, I have no problem selecting data, but I cant seem to be able to insert. If someone could see where im going wrong <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
2
7053
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
7
2508
by: dongletran06 | last post by:
Hi, Please help me find out what wrong with my codes in inputting from my form to mysql database using drop down menu. Below is the codes I used. Only the drop down is not working but the "input text" are successfully adding data to mysql. I just try first using the month as drop down. The month data type I used in mysql database is varchar. Im new in PHP please help me. Thanks <?php /* Created on: 10/12/2006 */ ?> <html> <body> <?php...
3
6478
by: ctrap | last post by:
Hi Everyone, Here's my situation: I'm making a website for an employment agency, there is a page where potential employees can visit and "pre-register". When the submit button is hit the information is supposed to be stored in a MySQL database. Number one, when I hit submit nothing happens. I have to manually execute the PHP script. When the PHP script is executed it inserts a blank record into the database and I get my Thank You...
2
3206
by: adamace5o | last post by:
When i try to use post variables with php and mysql i can't get the insert into statement to accept varibles as values. If i use 'test' instead of $test it does work. I suspect it is something to do with the javascript im using but i can print the correct values so why am i unable to use them to enter data to a database? sorry i am new to all this here is the updatedata.php file <?php session_start(); $host="localhost"; // Host...
0
3357
by: brianrpsgt1 | last post by:
I am attempting to insert data from a HTML form using a .psp script. I can not find how to link the data that is inserted into the form to the variables in the .psp script to then insert into the MySQL Insert statement. I am familiar with PHP, where you would write $_POST(), however I can not find the equivalent in PSP. I believe that this is the my missing piece. Technically, what is occurring that that when I click the 'Submit'...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.