| | |
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: 293
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 ajax apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail match menu mlm mod_rewrite multiple mysql oop paypal pdf php problem protocol query radio random recursion regex remote script search server sessions sms smtp soap source space sql strip_tags survey syntax system table tutorial undefined update upload url validation validator variable video virus votedown web window.onbeforeunload=closeme; xml youtube





