PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have three text fields ( hosteladmissionnumber,branch & Semester) and three text boxes in a form. When i provide the hostel admission number , the corresponding branch semester must be acquired from the registrationtable in DB and fill it in text boxes. How can i do it? any help would be appreciated. Thanks. I have pasted the code below.
<?php
session_start();
$hostad=$_POST['hosteladmissionno'];
$sem=$_POST['student_name'];
$sem=$_POST['semester'];
$con=mysql_connect('localhost','root','');
if(!$con)
{
die('Unable to connect'.mysql_error());
}
mysql_select_db('hostel',$con);
//i have to insert the hosteladmission in payment too..but no need to insert semester and branch
$r1="INSERT INTO payment(hosteladmissionno) values ('$hostad')";
mysql_close($con);
?>
/HTML PART
<form action='payment.php' method='POST' name='form1'>
<center>
<table>
<tr><td><b>Admission No:</b></td><td><input type='text' name='hosteladmissionno'></td></tr>
<tr><td><b>Student Name:</b></td><td><input type='text' name='student_name'></td></tr>
<tr><td><b>Semester:</b></td><td><input type='text' name='semester'></td></tr>
In order to fill in a text box based on what a user enters in a different text field you will need to use a little Javascript. I would recommend familiarizing yourself with jQuery and the AJAX functionality to make this work the best.
This assumes that your getSemester.php file uses the "hosteladno" as a POSTed variable to find the semester value in the database, then simply echo's the semester value.