Forum Moderators: coopster

Message Too Old, No Replies

Inserting data into MySql with PHP

Saving records from a simple form with PHP

         

digi_mind

4:35 pm on Mar 10, 2003 (gmt 0)

10+ Year Member



This is a simple problem and I hope to get a simple solution and a good example code:

I want to make a web site that allows the user to enter two values: Name and Password.

Once the user press "Enter" or whatever, then those values should be saved into a database which is Mysql and the table name is my_test.

Anyone can give me the code for that?

jatar_k

5:22 pm on Mar 10, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



How about I give you some pointers to how it should work.

You need a form, two textboxes and a submit button. The form method should be set to post and the action should be your mysql insert script.

The script will then connect to the db using mysql_connect [php.net] and then select the proper db (if needed) using mysql_select_db [php.net].

You can then build your query, something like
$sql = "insert into tablename values('$user','$pass')";

Then execute the query using mysql_query [php.net].

You can then send them off to some thank you page using header [php.net]