here is a code for HTML form
[code]
**<html>
<head>
<title>Registration Form</title>
</head>
<body>
<form action="registration.php" method="post">
<fieldset>
Name: <input type="textbox" name="fname"/><br/><br/>
Last Name: <input type="textbox" name="lname"/><br/><br/>

    Gender:<select><option value="text">Male</option><option value="text">Female</option></select><br><br>
    Address:        <input type="textbox" name="address"/><br/><br/>
    Contact:    <input type="textbox" name="contact"/><br/><br/>
    E-mail:         <input type="textbox" name="e-mail"/><br/><br/>
    User_Name:  <input type="textbox" name="user_name"/><br/><br/>

    Password:       <input type="password" name="password"/><br/><br/>
    Re-enter Password:  <input type="password" name="re-password"/><br/><br/>
    <br/><br/>
    <input type="submit" value="Register" name="Register"/> <input type="reset" value="Refill"/>
    </fieldset>
    </form>
</body>
</html>**

[/code]

PHP code is as follows:

**<?php $host="localhost"; //host name of service provider $user="root"; //user name of MySQL log-in //$pass=""; //password for MySQL log-in

//connecting to MySQL through localhost $con=mysql_connect($host,$user,"") or die("Can't connect to MySQL!");

//choosing database in which data to be stored $db="blogger";

//connecting to database $select=mysql_select_db($db,$con) or die("Can't connect to database !");

$fname=$_POST['fname']; $lname=$_POST['lname']; $address=$_POST['address']; $contact=$_POST['contact']; $e_mail=$_POST['e-mail']; $user_name=$_POST['user_name']; $password=$_POST['password']; $rpassword=$_POST['re-password'];

if($_SERVER['REQUEST_METHOD']=='POST') { echo "inside server!
";** **if(empty($fname)) die("Plese fill the First Name Field !
"); elseif(empty($lname)) die("Plese fill the last name !
"); elseif(empty($e_mail)) die("Please fill the e-mail ID !
"); elseif(empty($user_name)) die("Please fill the user-name!
"); elseif(empty($password)) die("Please fill the password!
"); elseif(empty($rpassword)) die("Please fill re-enter password field!
"); if(isset($_POST['Register'])) { echo"Connected!
"; } else echo "Registration Failed"; } mysql_close($con);** ?>

Plese somebody tell me where I am going wrong??

Member Avatar for Avenirer

What do you mean by "where I am going wrong?". You closed the connection without inserting the data in the database (not to mention the fact that you didn't check if the passwords are the same, and the fact that you didn't filter the data).

you should have done something like...

if(isset($_POST['Register']))
{
    mysql_query("INSERT INTO usertable (fname, lname, pass, etc) VALUES ('{$fname}', '{$lname}', '{$pass}', '{$etc}')");
    mysql_close($con);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.