| | |
Php page containing html form to sql database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2008
Posts: 42
Reputation:
Solved Threads: 0
Happy Holidays!
I have a one field form. Upon submission with the submit button, I wish to drive this field value into my SQL database table called MEMBERS and field called NAMES, thus adding a new record.
Can this be done with an OnSubmit() call to a function, in the HEAD of the HTML form page, which contains a series of statements opening the database, entering the data, and closing the database?
I have a one field form. Upon submission with the submit button, I wish to drive this field value into my SQL database table called MEMBERS and field called NAMES, thus adding a new record.
Can this be done with an OnSubmit() call to a function, in the HEAD of the HTML form page, which contains a series of statements opening the database, entering the data, and closing the database?
PHP Syntax (Toggle Plain Text)
<tr> <td class="mystyle">Your Full Name:</td> <td><input type="text" name="Name" size="30"></td> </tr>
•
•
Join Date: Apr 2008
Posts: 290
Reputation:
Solved Threads: 11
Create table in mysql--
create database in mysql with name db_name
in your php file you have to write like
your form structure like this
create database in mysql with name db_name
PHP Syntax (Toggle Plain Text)
CREATE TABLE `table_user` ( `user_id` int(2) NOT NULL auto_increment, `user_fname` varchar(10) NOT NULL, `user_lname` varchar(10) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1123 ;
in your php file you have to write like
PHP Syntax (Toggle Plain Text)
$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } else { // echo('Connected with Mysql'); } @mysql_select_db("db_name", $con);// connect to database db_name if (isset($_POST['Submit'])) { $sql="INSERT INTO table_user (user_fname, user_lname) VALUES('$_POST[user_fname]','$_POST[user_lname]')"; @mysql_query($sql,$con);
your form structure like this
PHP Syntax (Toggle Plain Text)
<table> <td width="141" align="left" valign="top" >First Name</td> <td width="163" align="left" valign="top"><input name="user_fname" type="text" id="user_fname"></td> <td align="left" valign="top" >Last Name</td> <td colspan="4" align="left" valign="top"><input name="user_lname" type="text" id="user_lname"> <input name="Submit" type="submit" value="Submit" > </table>
Last edited by Aamit; Dec 15th, 2008 at 8:51 am.
![]() |
Similar Threads
- AJAX comment form (JavaScript / DHTML / AJAX)
- PHP help in creating profile thingy (PHP)
- php login page problem (PHP)
- php drop down menu to search multiple sql tables (PHP)
- get html element value using php (PHP)
- php & mysql (MySQL)
- question about connecting odbc to sql through php script (PHP)
- Zend PHP Certification (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP Date always returns 0
- Next Thread: Testing
| Thread Tools | Search this Thread |
.htaccess apache api array autocomplete beginner binary body broken cakephp class cms code convert cron curl database dataentry date date/time display duplicates dynamic ebooks email emptydisplayvalue error execute explodefunction file firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include ip javasciptvalidation javascript joomla keywords limit link login mail matching mediawiki menu methods multiple mycodeisbad mysql network number object oop paypal pdf php phpincludeissue query random recursive redirect remote script search securephp server sessions shot source sp space speed sql subdomain subscription system table tag tutorial tutorials upload url validator variable vbulletin video web white youtube





