English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a database set up i have a page set up on my website a form that the user fills out after hitting submit THE FORM.HTM SHOULD GO TO TO SCRIPT.PHP and insert the record in my database through phphmyadmin it is not working what is the best way to do the php side of things?

2007-03-14 06:12:56 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

Your php page will need to connect to the database directly using one of many PHP functions designed for your database type.

For instance there are PHP functions to connect through MySQL, SQL, or plain ODBC. I have put links to PHP reference pages for these functions.

This initial task of setting up PHP to connect to the database is usually the toughest part of setting up a website database. Many things can prevent you from connecting...

1) It doesn't recognize you as a valid user
2) Your connection string is missing information or the information is incorrect
3) Your database doesn't support the connection you are attempting to make (wrong or bad driver)

Once you have established a link and have it working, you will need to execute a SQL statement which inserts the record. To do this you need a statement like....

INSERT INTO TABLE (column1, column2) VALUES('value1','value2')

You then use the PHP execute method for the database you are using... mysql_query() for mysql or mssql_query() for SQL Server.

Hope the links below make things a bit more clear. Good luck with this!

2007-03-14 11:13:26 · answer #1 · answered by Martyr2 7 · 0 0

First of all, ur form must have this attribute (method="post").
Now on script.php, you can get all of the form fields like this
$_POST['form-field-name'];

Connect to database.
Make a query to insert the database.
And run the query on database.
It will work.

2007-03-15 00:31:37 · answer #2 · answered by Atif Majid 3 · 0 0

fedest.com, questions and answers