0

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>

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by sibymary
0

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

Edited by divyakrishnan: n/a

0

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

Edited by sibymary: n/a

0

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

0

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";
}

Edited by karthik_ppts: n/a

0

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

This question has already been answered. 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.