0

Hi,

I have created table in database mysql and I created register form and I wrote insert code ,when we run the php file there is no but given data is not inserted in database....I need help,I am new to php....


This is my code i have used,........

<?php
if(isset($_POST)){
$host= "localhost";
$username= "root";
$password= "";
$db_name= "register";
$tbl_name="form";

mysql_connect("$host","$username","$password") ;
mysql_select_db("$register") ;

$fname= $_POST;
$lname =$_POST;
$eid =$_POST;
$pwd=$_POST;
$cpwd=$_POST;

$sql="INSERT INTO $form (id , fname ,lname, eid , pwd,cpwd) VALUES('NULL',' $fname','$lname','$eid','$pwd','$cpwd')";
$result=mysql_query($sql);

// close connection
mysql_close();
}

?>

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by vibhaJ
0

use die(mysql_error()) to see whats wrong into your query.

<?php
if(isset($_POST['submit'])){
$host= "localhost";
$username= "root";
$password= "";
$db_name= "register";
$tbl_name="form";

mysql_connect("$host","$username","$password") or die(mysql_error());;
mysql_select_db("$register") or die(mysql_error());;

$fname= $_POST['fname'];
$lname =$_POST['lname'];
$eid =$_POST['eid'];
$pwd=$_POST['pwd'];
$cpwd=$_POST['cpwd'];

$sql="INSERT INTO $form (id , fname ,lname, eid , pwd,cpwd) VALUES('NULL',' $fname','$lname','$eid','$pwd','$cpwd')";
$result=mysql_query($sql) or die(mysql_error());

// close connection
mysql_close();
}

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