| | |
how to enter data in database from HTML form
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2009
Posts: 2
Reputation:
Solved Threads: 0
I am trying to use this script to enter data into my database from an html form. this code is not working. plz tell me where the error is
form is
and the action file is
form is
html Syntax (Toggle Plain Text)
<html> <head> <title> Review, Ratings, Opinions Site </title> </head> <body text="green" > <form action="register processing.php" method="post" > First name: <input type="text" name="fname" value="empty" /> <br/> Last name: <input type="text" name="lname" value="empty" /> <br/> Gender:<br/><input type="radio" name="sex" value="male" /> MALE <input type="radio" name="sex" value="female" /> FEMALE <br/> Email id: <input type="text" name="email" value="empty" /> <br/> Username: <input type="text" name="username" value="empty" /> <br/> password: <input type="password" name="password" value="empty" /> <br/> <input type="submit" name="submit" value="submit" /> </form> </body> </html>
and the action file is
php Syntax (Toggle Plain Text)
<?php $handle = mysql_connect("localhost", "root"); if(!$handle) die("mysql connection failed due to :" . mysql_error()); $db = mysql_select_db ("review_site" , $handle ); if(!db) die("database selection failed due to :" . mysql_error()); ?> <html> <head> <title> server side proceesing </title> </head> <body> <?php $fname = $_REQUEST['fname']; $lname = $_REQUEST['lname']; $sex = $_REQUEST['sex']; $email= $_REQUEST['email']; $username=$_REQUEST['username']; $password= $_REQUEST['password']; $v= 1; $sql = "INSERT INTO users(fname,lname,sex,email,username,password,visible) VALUES($fname,$lname,$sex,$email,$username,$password,$v)" ; if($result = mysql_query ($sql, $handle )) {echo "welcome " . $fname . "<br/>";} ?> </body> </html>
Last edited by Ezzaral; Aug 18th, 2009 at 4:39 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
![]() |
Similar Threads
- How to Insert/Edit data from TAG SELECT HTML Form to MySQL Database? (PHP)
- how to receive data from html form...? (HTML and CSS)
- Php page containing html form to sql database (PHP)
- get data from HTML form (Java)
- Retrving data from database to form (PHP)
- Error loading data from database (PHP)
- Cannot get php script to enter data (MySQL)
- Problem inserting data into database (JSP)
- Login and retrieve user data from database (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: Intergrating javascript with php / mysql
- Next Thread: update query
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error errors execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javascript joomla keywords limit link login loop mail menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect remote script search securephp server sessions shot sms source space sql subscription syntax system table tutorial tutorials update upload url validator variable video web youtube





