How to link a form to a database??

I have been trying to link a form that i created to a database… But it just doesn’t seem to be happening… :frowning:
Can anyone please have a look at the php code given below and let me know where the error lies??

[php]

<?php $username=$_POST['name']; $gender=$_POST['gender']; $dateOfBirth=$_POST['dateOfBirth']; $eMailId=$_POST['eMailId']; $college=$_POST['college']; $password=$_POST['password']; $repassword=$_POST['rePassword']; include('C:\xampp\htdocs\dwd\conn.php'); $sql = "INSERT INTO userinfo VALUES('','".$username."','".$password."','".$gender."','".$dateOfBirth."','".$college."','".$emailid."')"; if($password!=$repassword) { include('C:\xampp\htdocs\dwd\signup.php'); } else { mysql_query($sql,$con); include('C:\xampp\htdocs\dwd\success.php'); } ?>

[/php]

Thanks a ton in advance!! :slight_smile:

please post your database schema and your connection code.

The connection link is :

[php]

<?php $con = mysql_connect("localhost","root","") or die();; mysql_select_db("db_login",$con); ?>

[/php]

SCHEMA :

db_login.userinfo
userId : int(11)
username : varchar(255)
password : varchar(255)
gender : char(7)
dateOfBirth : date
college : varchar(40)
eMailId : varchar(255)

are you using

action = “post”

on form tag, does input field names match requested $_POST[‘Field name’] vars?

Sponsor our Newsletter | Privacy Policy | Terms of Service