heshan Posted August 14, 2012 Share Posted August 14, 2012 Hi guys, In the below form when a user enters an admission number and click on the relevant type report the report was generated. ..Then I want something like this.When a user enters an admission number which is already existing, a validation should come as "The number already existed". How can i do that? <form name="form1" method="post" action="certificaterValid.php"> <table width="850" border="1" align="center" bgcolor="#00FFFF"> <tr> <td colspan="2"><table width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="25%"><img src="../IMAGE/banner - Copy.jpg" alt="" width="186" height="136" /></td> <td width="75%" align="center" valign="middle"><div align="center"><img src="../IMAGE/banner.jpg" alt="" width="733" height="137" /></div></td> </tr> </table></td> </tr> <tr> <td width="170"> </td> <td width="664"><table width="657" border="0"> <tr> <td width="124"><a href="../../Home page/new student registration/add_or_manage.php">Manage Data</a></td> <td width="124"> </td> <td width="124"> </td> <td width="124" align="center"><a href="../add admin users/changePasword.php">Change Password</a></td> <td width="129" align="center"><a href="../Home page/new student registration/signout.php">Signout</a></td> </tr> </table></td> </tr> <tr> <td height="59" valign="top"><ul id="MenuBar1" class="MenuBarVertical"> <li><a href="../../add admin users/add techer/addAdminUser.php">Add Admin Login</a> </li> <li><a href="../../Student registration/new student registration/newStudentRegistrationForm.php">Add Student</a></li> <li><a href="../../student attendance/add attendance/addStudentAttendance.php">Add Student Attendance</a> </li> <li><a href="../../Student time table/add1 time table/addTimeTable.php">Add Time Table</a></li> <li><a href="../../Student marks/add student marks/addStudentMark.php">Add Student Marks</a></li> <li><a href="../../manage subject/add subject.php">Add Subject</a></li> <li><a href="../../search student information/SearchStudentInformation.php">Search Student Information</a></li> <li><a href="../../student payments reports/studentsPayments.php">Student Payment Reports</a></li> <li><a href="../../Issue certificate/issueCertificate.php">Issue Certificates</a></li> </ul> <p> </p> <p> </p></td> <td valign="top"><table width="659" border="0"> <tr> <td> </td> <td colspan="8"> </td> </tr> <tr> <td width="14"> </td> <td colspan="8"><h3> <label>Issue cretificate</label> </h3></td> </tr> <tr> <td> </td> <td width="153"> </td> <td width="3"> </td> <td width="128"> </td> <td width="32"> </td> <td width="60"> </td> <td width="55"> </td> <td width="55"> </td> <td width="66"> </td> </tr> <tr> <td> </td> <td><label>Admission No</label> </td> <td> </td> <td> <center> <div > <input type="text" onkeyup="getScriptPage('box','text_content')" id="text_content" size="40" name="admission_no" /> <div id="box"></div> </div> </center> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label>Issue Cetificate</label> </td> <td> </td> <td> <select name="report" id="jumpMenu" > <option value="l">Leaving</option> <option value="c">Character</option> <option value="r">Recommendation</option> </select> </td> <td> </td> <td> <input type="submit" name="Submit" id="button" value="Issue" onClick="return Validate();"/> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <p> </p> <p> </p></td> </tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 14, 2012 Share Posted August 14, 2012 I don't see any PHP code in there. So I have to ask: Have you started on the PHP code at all, or did you simply forget to post the code here? In either case. What you need to do, is to store the numbers somewhere (like in a database), and then compare the newly submitted number against what already exists in the database. If you get any rows returned, then you know it's a number which is already taken. Then show the message, and repopulate the form. Quote Link to comment Share on other sites More sharing options...
heshan Posted August 14, 2012 Author Share Posted August 14, 2012 Yeah i forgot to post the PHP coding.. Here is this..How can i edit the coding to fulfill my above requirement? Appreciate if you can give me the coding.. <?php $admission_no=$_POST["admission_no"]; $report=$_POST["report"]; $date=date("Y-m-d"); $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); if($report=="l"){ $query="insert into certificate values(null,'$admission_no','$report','$date')"; $result=mysql_query($query); header("location:leavingCertificate.php?admission_no=".$admission_no."&report=".$report); exit(); } if($report=="c"){ $query="insert into certificate values(null,'$admission_no','$report','$date')"; $result=mysql_query($query); header("location:characterCertificate.php?admission_no=".admission_no."&report=".$report); exit(); } if($report=="r"){ $query="insert into certificate values(null,'$admission_no','$report','$date')"; $result=mysql_query($query); header("location:recommendLetter.php?admission_no=".$admission_no."&report=".$report); exit(); } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 14, 2012 Share Posted August 14, 2012 This is a forum to get help, not to get people to write your code. "Appreciate if you can give me the coding.." it doesn't matter how many nice words you put, it's still rude. You need to try on your own. Do you know how to read data from your database? Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 14, 2012 Share Posted August 14, 2012 Why are you repeating the IF-blocks, where the only difference is the value you're testing against? Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted August 14, 2012 Share Posted August 14, 2012 Please note that this is not a board for "give me the coding." We're here to help you learn, not to do it for you. Also, please try to include a better subject next time. Only one person is helping you because you posted a thread titled "need PHP coding help" in a forum called..."PHP Coding Help." Quote Link to comment Share on other sites More sharing options...
heshan Posted August 16, 2012 Author Share Posted August 16, 2012 Hi all, I accepted my fault..I have worded in improper manner. Anyway thanks for the guidance... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.