hi,im using registration form for registering users to the new account.i have 2 tables in one database.database name is test and table name is student and member.in student table which contain the register no of student which is already stored in the database.in member table,it has 4 fields which is name,register no,address,email id.when a student registered,the register no of student should be same as the registerno in the student table which is already exist.
i had tried to overcome this problem.but didnt get the proper answer for this..
Any help would be appreciated.

thank you
this is my php page

<html> 
<body>
<html>
<head>
<body>
<?php
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$regno = $_POST['regno'];
$dept = $_POST['dept'];
$valid = $_POST['valid'];
$dob = $_POST['dob'];
$address = $_POST['address'];
$emailid = $_POST['emailid'];
$con = mysql_connect("localhost");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("test", $con);
$sql="INSERT INTO member (fname,lname,regno,dept,valid,dob,address,emailid) VALUES('$fname','$lname','$regno','$dept','$valid','$dob','$address','$emailid')";
mysql_query($sql)  or die(mysql_error());
$result="SELECT student.regno, member.regno if(member.regno=student.regno,"register");"
 or die(mysql_error());

mysql_close($con)
?>
<a href="library.html" target="_parent">home</a>
</body>
</html>

Recommended Answers

All 5 Replies

Do u want to check the register no in member table before inserting it into student table?

no....in student table,the register no s already exist
but in member table,when a new user is requesting for the membership,he have to fill the registeration form ,it contain register no which should be equal to the register no of student table.then only his registration form values are entering to the member table.
student table ->exixting table
member table ->inserting values by student
the register no of member table refer to the register no of student table

the register no of student table and member table should be same ,then only data will inserted into the member table

Try this

$rs_stud=mysql_query("select * from student where regno='$regno'");
$count=mysql_num_rows($rs_stud);
if($count>0)
{
$sql="INSERT INTO member (fname,lname,regno,dept,valid,dob,address,emailid) VALUES('$fname','$lname','$regno','$dept','$valid','$dob','$address','$emailid')";
mysql_query($sql) or die(mysql_error());
}
else
{
echo "Sorry! You Can't Register.There is no student found with this register no $regno";
}

Hey,Thanks for the reply.helpful to me your answer
thanks karthik

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.