Jump to content

ray92

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by ray92

  1. Hey all I'm very beginners level and I realize now that my group have chosen a project for our capstone that is beyond our knowledge, I was able to create a Login and Registration pages without issues and am also able to save it in the database but I have been struggling to understand why am I getting the two errors bellow. What I'm trying to achieve is displaying the 'studentid' and save all the information input on the form in the table 'courseenrolls'. If anyone could enlighten me with what's wrong and how to solve would be much appreciated. Here is the code for the index page. session_start(); include('config2.php'); include('dbconn.php'); if(isset($_POST['submit_enrol'])) { $studentid=mysqli_real_escape_string($_POST['studentid']); $year=mysqli_real_escape_string($_POST['year']); $term=mysqli_real_escape_string($_POST['term']); $coursetimetable1=mysqli_real_escape_string($_POST['coursetimetable1']); $coursetimetable2=mysqli_real_escape_string($_POST['coursetimetable2']); $coursetimetable3=mysqli_real_escape_string($_POST['coursetimetable3']); $coursetimetable4=mysqli_real_escape_string($_POST['coursetimetable4']); $ret= mysqli_query ($con,"INSERT INTO courseenrolls(studentid,year,term,coursetimetable1,coursetimetable2,coursetimetable3,coursetimetable4) VALUES ('$studentid','$year','$term',$coursetimetable1','$coursetimetable2','$coursetimetable3', 'coursetimetable4')"); mysqli_query($db, $query); if($ret) { $_SESSION['msg']="Enrolled Successfully!"; } else { $_SESSION['msg']="Error: Not Enrolled"; } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Course Enrolment</title> <link rel="stylesheet" type="text/css" href="style2.css"> </head> <body> <font color="green" align="center"><?php echo htmlentities($_SESSION['msg']);?><?php echo htmlentities($_SESSION['msg']="");?></font> <?php $sql=mysqli_query($con,"SELECT * from user where studentid='".$_SESSION['login']."'"); $cnt=1; while($row=mysqli_fetch_array($sql)) ?> <div class="panel-body"> <form name="term" method="post" enctype="multipart/form-data"> <div class="form-group"> <label for="studentid">Student ID </label> <input type="text" class="form-control" id="studentid" name="studentid" value="<?php echo htmlentities($row['studentid']);?>" placeholder="studentid" readonly /> </div> <?php ?> <div class="form-group"> <label for="year">Select Your Current Study Year </label> <select class="form-control" name="year" required="required"> <option value="">Select Your Current Study Year</option> <?php $sql=mysqli_query($con,"select * from year"); while($row=mysqli_fetch_array($sql)) { ?> <option value="<?php echo htmlentities($row['year']);?>"><?php echo htmlentities($row['year']);?></option> <?php } ?> </select> </div> <div class="form-group"> <label for="term">Select The Term You are Enrolling In </label> <select class="form-control" name="term" required="required"> <option value="">Select The Term You are Enrolling In</option> <?php $sql=mysqli_query($con,"select * from term"); while($row=mysqli_fetch_array($sql)) { ?> <option value="<?php echo htmlentities($row['term']);?>"><?php echo htmlentities($row['term']);?></option> <?php } ?> </select> </div> <div class="form-group"> <label for="coursetimetable1">Select First Course </label> <select class="form-control" name="coursetimetimetable1" required="required"> <option value="">Select First Course</option> <?php $sql=mysqli_query($con,"select * from coursetimetable1"); while($row=mysqli_fetch_array($sql)) { ?> <option value="<?php echo htmlentities($row['courseday']);?>"><?php echo htmlentities($row['courseday']);?></option> <?php } ?> </select> </div> <div class="form-group"> <label for="coursetimetable2">Select Second Course </label> <select class="form-control" name="coursetimetimetable2"> <option value="">Select Second Course</option> <?php $sql=mysqli_query($con,"select * from coursetimetable2"); while($row=mysqli_fetch_array($sql)) { ?> <option value="<?php echo htmlentities($row['courseday']);?>"><?php echo htmlentities($row['courseday']);?></option> <?php } ?> </select> </div> <div class="form-group"> <label for="coursetimetable3">Select Third Course </label> <select class="form-control" name="coursetimetable3"> <option value="">Select Third Course</option> <?php $sql=mysqli_query($con,"SELECT * FROM coursetimetable3"); while($row=mysqli_fetch_array($sql)) { ?> <option value="<?php echo htmlentities($row['courseday']);?>"><?php echo htmlentities($row['courseday']);?></option> <?php } ?> </select> </div> <div class="form-group"> <label for="coursetimetable4">Select Fourth Course </label> <select class="form-control" name="coursetimetable4"> <option value="">Select Fourth Course</option> <?php $sql=mysqli_query($con,"SELECT * FROM coursetimetable4"); while($row=mysqli_fetch_array($sql)) { ?> ?> <option value="<?php echo htmlentities($row['courseday']);?>"><?php echo htmlentities($row['courseday']);?></option> <?php } ?> </select> </div> <button type="submit_enrol" name="submit_enrol" id="submit_enrol" class="btn btn-default">Enroll</button> <button><a href="logout.php" class="btn btn-default">Logout</a> </button>; </div> </form> </body> </span> </div> </form> </div> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.