Computing.Net > Forums > Web Development > PHP Form saving to mySQL

PHP Form saving to mySQL

Reply to Message Icon

Original Message
Name: kyleinc
Date: June 22, 2004 at 17:21:00 Pacific
Subject: PHP Form saving to mySQL
OS: linux
CPU/Ram: ?
Comment:

I am rewriting my web site in php to take advantage of mySQL. Currently, I am trying to take the contents of a text field (like the kind one types in to make a post on this board) of a form and save it to an entry in my SQL database. However, being new to php and all, I don't exactly know how to accomplish this. Can anybody point me in the right direction?


Report Offensive Message For Removal


Response Number 1
Name: anonproxy
Date: June 22, 2004 at 18:23:47 Pacific
Subject: PHP Form saving to mySQL
Reply: (edit)

It's fairly simple. CGI-like behavior means that scripts and the server exchange data (that's the short version). In PHP, there are global arrays, called superglobals, which hold user input via HTML forms. By specifying in the HTML form "action:" field a PHP script which is ready to use data in a superglobal, the server fills the array(s) with form data when the submit request is sent. In this way, the script is executed and gets immediate access to the user's input.

Using MySQL involves opening a connection (which means loging in to mysqld, the database server), filling in an SQL query with some data from the HTML form, and submiting it to mysqld. Of course, you should have a table already setup to be filled.

Try Google for "php html form input" and maybe through mysql in there too. The PHP online manual at php.net covers things like superglobals and mysql functions. This topic is covered extensively in most books about PHP as well.



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: PHP Form saving to mySQL

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software