here is a code for HTML form
<title>Registration Form</title>
<form action="registration.php" method="post">
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/>
    <input type="submit" value="Register" name="Register"/> <input type="reset" value="Refill"/>


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??

Edited by samidha: Code wasn't given properly

5 Years
Discussion Span
Last Post by 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...

    mysql_query("INSERT INTO usertable (fname, lname, pass, etc) VALUES ('{$fname}', '{$lname}', '{$pass}', '{$etc}')");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.