nehaperiyasamy Ответов: 1

Почему данное значение становится равным 0 при сохранении значения в базе данных


<?php
@ob_start();
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CECRI KARAIKUDI</title>
<?php
include('css.php');
?>
</head>
<body>
<div class="row" align="center"><a href="index.php"><img src="img/header.png" class="img img-responsive" alt="" align="center" /></div><div class="clear_fix"></div><div class="row header_bot"><div class="col-sm-8"></div><div class="col-sm-4 pull-right" align="right">
	<?php if(isset($_SESSION['username'])){ ?>
    	 <span class="header_bot_span"><a href="logout.php">Logout</a></span>
    <?php } else { ?>
        <span class="header_bot_span"><a href="admin.php">Admin</a></span>
        <span class="header_bot_span"><a href="student_login.php">Student</a></span>
    <?php } ?>
 </div>
</div>
<div class="clear_fix"></div>

<!-- Start Content -->
	<div class="clearfix"></div>
<div class="row strip">
	  <a href="index.php"><span class="strip_font">Home</span></a> / <a class="active" href=""><span class="strip_font" style="color:#C00;">Add Daily Attendance</span></a>
</div>
<div class="clearfix"></div>


<div class="col-md-12">
<div class="col-md-3 left_side_menu">
	<?php
    error_reporting(0);
	 include('db.php');
     include('admin_menu.php');
	 if(isset($_SESSION['username'])){
	if(isset($_POST['submit'])){
		//print_r($_POST);die;
		$roll = $_POST['roll_no'];
		$name = $_POST['name'];
		$class = $_POST['class'];
		$date = $_POST['date'];
		$subject_name_and_subject_code = $_POST['subject_name_and_subject_code'];
		$subject_handle_by = $_POST['subject_handle_by'];
		$batch=$_POST['batch'];
		$semester=$_POST['semester'];
		$period=$_POST['period'];
        $present = $_POST['atten'];
        // echo "INSERT INTO daily_atten(id, roll_no, class, date, subject_name_and_subject_code, subject_handle_by, batch, semester, period1, present) VALUES ('$roll_no','$class','$date','$subject_name_and_subject_code','$subject_handle_by','$batch','$semester','$period','$present')");
        $sql = $db->query("INSERT INTO `daily_atten`(`id`, `roll_no`, `class`, `date`, `subject_name_and_subject_code`, `subject_handle_by`, `batch`, `semester`, `period1`, `present`) VALUES ('$id','$roll_no','$class','$date','$subject_name_and_subject_code','$subject_handle_by','$batch','$semester','$period1','$present')");
		if($sql){
			echo "<script>alert('Details Saved Successfully');</script>";
		}else{
			echo "<script>alert('Failed to Save the details. Please Check');</script>";	
		}
    }
    // die();
    ?>
</div>
<div class="col-md-9 col-sm-9 col-xs-12 content_border" style="margin-top:10px; padding:10px;">
<h3 style="font-weight:bold; text-transform:uppercase; padding-bottom:5px;"> Add Student Attendance (Daily)</h3>
<div class="row">
<div class="col-md-6 ol-sm-6 col-xs-12">
<table class="table table-bordered table-responsive">
<?php
	$query = $db->query("select * from class") or die(mysqli_error());
?>
<form method="post" action="" enctype="multipart/form-data">
<tr>
	<th>Student Roll No.</th>
    <td><input type="text" name="roll_no"  placeholder="roll_no"  class="form-control my_form" required="required" /></td>
</tr>
<tr>
	<th>Student Name</th>
    <td><input type="text" name="name"  placeholder="Student Name" class="form-control my_form" required=" required" /></td>
</tr>
<tr>
	<th>Class</th>
    <td><select name="class" class="form-control my_form">
	<?php
        while($row = mysqli_fetch_assoc($query)){ ?>
                <option value="<?php echo $row['class_name']; ?>"><?php echo $row['class_name']; ?></option>
    <?php } ?>
		</select>
    </td>
</tr>
<tr>
	<th>Date</th>
    <td><input type="date" name="date" class="form-control my_form" placeholder="mm/dd/yyyy" required /></td>
</tr>
<tr>
	<th>subject name and subject code</th>
    <td>
    	<select name="subject_name_and_subject_code" required="required" class="form-control my_form">
            <option value="">subject name and subject code</option>
            <option value="HS851-TECHNICAL ENGLISH:(4004)-(II-SEM)">HS851-TECHNICAL ENGLISH:(4004)-(II-SEM)</option>
            <option value="MA8251-ENGINEERING MATHEMATICS-II:(4004)-(II-SEM)">MA8251-ENGINEERING MATHEMATICS-II:(4004)-(II-SEM)</option>
            <option value="PH8254-PHYSICS OF MATERIALS:(3003)-(II-SEM)">PH8254-PHYSICS OF MATERIALS:(3003)-(II-SEM)</option>
            <option value="CY8292-CHEMISTRY FOR TECHNOLOGISTS:(3003)-(II-SEM)">CY8292-CHEMISTRY FOR TECHNOLOGISTS:(3003)-(II-SEM)</option>
            <option value="BE8251-BASIC ELECTRICAL AND ELECTRONICS ENGINEERING:(3003)-(II-SEM)">BE8251-BASIC ELECTRICAL AND ELECTRONICS ENGINEERING:(3003)-(II-SEM)</option>
            <option value="EL8201-PRINCIPLES OF ELECTROCHEMISTRY:(3003)-(II-SEM)">EL8201-PRINCIPLES OF ELECTROCHEMISTRY:(3003)-(II-SEM)</option>
            <option value="MA6459-NUMERICAL METHODS:(3104)-(IV-SEM)">MA6459-NUMERICAL METHODS:(3104)-(IV-SEM)</option>
<option value="CH6455-CHEMICAL ENGINEERING THERMODYNAMICS:(3104)-(IV-SEM)">CH6455-CHEMICAL ENGINEERING THERMODYNAMICS:(3104)-(IV-SEM)</option>
<option value="EL6401-CHEMICAL RECTION ENGINEERING:(3003)-(IV-SEM)">EL6401-CHEMICAL RECTION ENGINEERING:(3003)-(IV-SEM)</option>
<option value="CH6460-MATERIAL TECHNOLOGY:(3003)-(IV-SEM)">CH6460-MATERIAL TECHNOLOGY:(3003)-(IV-SEM)</option>
<option value="EL6402-HEAT TRANSFER AND ITS APPILCTION:(3003)-(IV-SEM)">EL6402-HEAT TRANSFER AND ITS APPILCTION:(3003)-(IV-SEM)</option>
<option value="EL6403-PRINCIPLES OF ELECTROCHEMISTRY:(3003)-(IV-SEM)">EL6403-PRINCIPLES OF ELECTROCHEMISTRY:(3003)-(IV-SEM)</option>
<option value="EL6601-ELECTROCHEMICAL MATERIALS SCIENCE:(3003)-(VI-SEM)">EL6601-ELECTROCHEMICAL MATERIALS SCIENCE:(3003)-(VI-SEM)</option>
<option value="CH6653-MASS TRANSFER-II:(3003)">CH6653-MASS TRANSFER-II:(3003)</option>
<option value="EL6602-INDUSTRIAL MATERIAL FINISHING:(3003)-(VI-SEM)">EL6602-INDUSTRIAL MATERIAL FINISHING:(3003)-(VI-SEM)</option>
<option value="EL6603-INSTRUMENTATION:(3003)-(VI-SEM)">EL6603-INSTRUMENTATION:(3003)-(VI-SEM)</option>
<option value="EL6604-ELECTROCHEMICAL PROCESS TECHNOLOGY:(3003)-(VI-SEM)">EL6604-ELECTROCHEMICAL PROCESS TECHNOLOGY:(3003)-(VI-SEM)</option>
<option value="EL6605-PROCESS DYNAMICS AND CONTROL:(3104)-(VI-SEM)">EL6605-PROCESS DYNAMICS AND CONTROL:(3104)-(VI-SEM)</option>
<option value="EL6801-ELECTROCHEMICAL ENERGY CONVERSION & STORAGE:(3003)-(VIII-SEM)">EL6801-ELECTROCHEMICAL ENERGY CONVERSION & STORAGE:(3003)-(VIII-SEM)</option>
<option value="EL6802 SURFACE SCIENCE:(3003)-(VIII-SEM)">EL6802 SURFACE SCIENCE:(3003)-(VIII-SEM)</option>
<option value="ELECTIVE-II EL6005 CATHODIC PROTECTION & ELECTROPHRETIC COATINGS-(VIII-SEM)">ELECTIVE-II EL6005 CATHODIC PROTECTION & ELECTROPHRETIC COATINGS-(VIII-SEM)</option>

            
        </select>
    </td>
</tr>
<tr>
	<th>Subject handle by</th>
    <td>
    	<select name="Subject_handle" required="required" class="form-control my_form">
            <option value="">subject handle by</option>
            <option value="Mr.THOMAS ALEXANDER,M.A.M.Phil(TECHNICAL ENGLISH)">Mr.THOMAS ALEXANDER,M.A.M.Phil(TECHNICAL ENGLISH)</option>
            <option value="Mr.S.SIVAKUMAR,M.Sc,M.Phil,P.G.D.C.A(ENGINEERING MATHS-II">Mr.S.SIVAKUMAR,M.Sc,M.Phil,P.G.D.C.A(ENGINEERING MATHS-II</option>
            <option value="Mr.D.SHERWOOD,M.Sc,P.G.D.C.A(ENGINEERING MATHS-II)">Mr.D.SHERWOOD,M.Sc,P.G.D.C.A(ENGINEERING MATHS-II)</option>
            <option value="Dr.V.SARANYAN,M.Sc,Ph.D(PHYSICS OF MATERIALS)">Dr.V.SARANYAN,M.Sc,Ph.D(PHYSICS OF MATERIALS)</option>
<option value="Dr.M.RAMESH,M.Sc,Ph.D(PHYSICS OF MATERIALS">Dr.M.RAMESH,M.Sc,Ph.D(PHYSICS OF MATERIALS</option>
<option value="Dr.A.SUBBIAH,M.Sc,Ph.D(CHEMISTRY FOR TECHNOLOGISTS)">Dr.A.SUBBIAH,M.Sc,Ph.D(CHEMISTRY FOR TECHNOLOGISTS)</option>
<option value="Dr.M.KATHIRESAN,M.Sc,Ph.D(CHEMISTRY FOR TECHNOLOGISTS)">Dr.M.KATHIRESAN,M.Sc,Ph.D(CHEMISTRY FOR TECHNOLOGISTS)</option>
<option value="Mr.P.THIPPERUDRASAMY.PGD(emb.sys).M.Tech(BASIC ELECTRICAL AND ELECTRONICS ENGINEERING)">Mr.P.THIPPERUDRASAMY.PGD(emb.sys).M.Tech(BASIC ELECTRICAL AND ELECTRONICS ENGINEERING)</option>
<option value="Er.V.GOPALAKRISHAN,B.E(BASICS ELECTRICAL AND ELECTRONICS ENGINEERING)">Er.V.GOPALAKRISHAN,B.E(BASICS ELECTRICAL AND ELECTRONICS ENGINEERING)</option>
<option value="Dr.J.MATHIYARASU,M.Sc,Ph.D(PRINCIPLES OF ELECTROCHEMISTRY)">Dr.J.MATHIYARASU,M.Sc,Ph.D(PRINCIPLES OF ELECTROCHEMISTRY)</option>
<option value="Dr.JAMES JOSEPH,M.Sc,Ph.D(PRINCIPLES OF ELECTROCHEMISTRY">Dr.JAMES JOSEPH,M.Sc,Ph.D(PRINCIPLES OF ELECTROCHEMISTRY</option>
<option value="Mr.S.SIVAKUMAR,M.Sc,M.Phil,P.G.D.C.A(NUMERICAL METHODS)">Mr.S.SIVAKUMAR,M.Sc,M.Phil,P.G.D.C.A(NUMERICAL METHODS)</option>
<option value="Mr.D.SHERWOORD,M.Sc,P.G.D.C.A(NUMERICAL METHODS)">Mr.D.SHERWOORD,M.Sc,P.G.D.C.A(NUMERICAL METHODS)</option>
<option value="Dr.R.MALINI,M.Tech,Ph.D(CHEMICAL ENGINEERING THERMODYNAMICS)">Dr.R.MALINI,M.Tech,Ph.D(CHEMICAL ENGINEERING THERMODYNAMICS)</option>
<option value="Dr.V.RAVI BABU,M.Tech,Ph.D(CHEMICAL REACTION ENGINEERING)">Dr.V.RAVI BABU,M.Tech,Ph.D(CHEMICAL REACTION ENGINEERING)</option>
<option value="Dr.L.JHON BERCHMANS,M.Tech,Ph.D(MATERIALS TECHNOLOGY)">Dr.L.JHON BERCHMANS,M.Tech,Ph.D(MATERIALS TECHNOLOGY)</option>
<option value="Dr.M.SATHISH,M.Sc,Ph.D(MATERIALS TECHNOLOGY)">Dr.M.SATHISH,M.Sc,Ph.D(MATERIALS TECHNOLOGY)</option>
<option value="Dr.G.SREEDHAR,M.Tech,Ph.D(HEAT TRANSFER AND ITS APPLICATIONS)">Dr.G.SREEDHAR,M.Tech,Ph.D(HEAT TRANSFER AND ITS APPLICATIONS)</option>
<option value="Dr.J.MATHIYARASU,M.Sc,PH.D(PRINICIPLES OF ELECTROCHEMISTRY)">Dr.J.MATHIYARASU,M.Sc,PH.D(PRINICIPLES OF ELECTROCHEMISTRY)</option>
<option value="Dr.JAMES JOSEPH,M.Sc,Ph.D(PRINICIPLES OF ELECTROCHEMISTRY)">Dr.JAMES JOSEPH,M.Sc,Ph.D(PRINICIPLES OF ELECTROCHEMISTRY)</option>
<option value="Dr.B.SUBRAMANIAN,M.Sc,Ph.D(ELECTROCHEMICAL MATERIALS SCIENCE)">Dr.B.SUBRAMANIAN,M.Sc,Ph.D(ELECTROCHEMICAL MATERIALS SCIENCE)</option>
<option value="Dr.N.LAKSHMINARASIMHAN,M.Sc,Ph.D(ELECTROCHEMICAL MATERIALS SCIENCE)">Dr.N.LAKSHMINARASIMHAN,M.Sc,Ph.D(ELECTROCHEMICAL MATERIALS SCIENCE)</option>
<option value="Dr.KARTHIK,M.Sc,Ph.D(ELECTROCHEMICAL MATERIALS SCIENCE)">r.KARTHIK,M.Sc,Ph.D(ELECTROCHEMICAL MATERIALS SCIENCE)</option>
<option value="Dr.V.MURUGAN,B.Phram,M.S,Ph.D(ELECTROCHEMICAL MATERIALS SCIENCE)">Dr.V.MURUGAN,B.Phram,M.S,Ph.D(ELECTROCHEMICAL MATERIALS SCIENCE)</option>
<option value="Dr.SUNDAR MAYAVAN,B.Tech,M.S.Ph.D(MASS TRANSFER)">Dr.SUNDAR MAYAVAN,B.Tech,M.S.Ph.D(MASS TRANSFER)</option>
<option value="Dr.R.SEKAR,M.Sc,M.Phil,Ph.D(INDUSTRIAL METAL FINISHING)">Dr.R.SEKAR,M.Sc,M.Phil,Ph.D(INDUSTRIAL METAL FINISHING)</option>
<option value="Dr.M.JAYAKUMAR,M.Sc,M.Phil,Ph.D(INDUSTRIAL METAL FINISHING)">Dr.M.JAYAKUMAR,M.Sc,M.Phil,Ph.D(INDUSTRIAL METAL FINISHING)</option>
<option value="Dr.N.RAJASHAKARANM.Sc,Ph.D(INDUSTRIAL METAL FINISHING)">Dr.N.RAJASHAKARANM.Sc,Ph.D(INDUSTRIAL METAL FINISHING)</option>
<option value="Dr.S.RADHAKRISHAN,M.Sc,Ph.D(INSTRUMENTATION)">Dr.S.RADHAKRISHAN,M.Sc,Ph.D(INSTRUMENTATION)</option>
<option value="Dr.G.SOZHAN,M.E,Ph.D(ELECTROCHEMICAL PROCESS TECHNOLOGY)">Dr.G.SOZHAN,M.E,Ph.D(ELECTROCHEMICAL PROCESS TECHNOLOGY)</option>
<option value="Dr.T.VIJAYABHARATHI,M.Sc,Ph.D(ELECTROCHEMICAL PROCESS TECHNOLOGY)">Dr.T.VIJAYABHARATHI,M.Sc,Ph.D(ELECTROCHEMICAL PROCESS TECHNOLOGY)</option>
<option value="Dr.V.SURIYANARAYANAN,M.Sc,Ph.D(ELECTROCHEMICAL PROCESS TECHNOLOGY)">Dr.V.SURIYANARAYANAN,M.Sc,Ph.D(ELECTROCHEMICAL PROCESS TECHNOLOGY)</option>
<option value="Dr.S.VENGATESAN,M.Sc,M.Tech,Ph.D(ELECTROCHEMICAL PROCESS TECHNOLOGY)">Dr.S.VENGATESAN,M.Sc,M.Tech,Ph.D(ELECTROCHEMICAL PROCESS TECHNOLOGY)</option>
<option value="Dr.R.MAYANDI,BTech,Ph.D(PROCESS DYNAMICS AND CONTROL)">Dr.R.MAYANDI,BTech,Ph.D(PROCESS DYNAMICS AND CONTROL)</option>
<option value="Dr.M.V.T.DHANAJEYAN,M.Sc,Ph.D(ELECTROCHEMICAL ENGERY CONVERSION &STORAGE)">Dr.M.V.T.DHANAJEYAN,M.Sc,Ph.D(ELECTROCHEMICAL ENGERY CONVERSION &STORAGE)</option>
<option value="Dr.M.RAJU,M.E,Ph.D(ELECTROCHEMICAL ENGERY CONVERSION &STORAGE)">Dr.M.RAJU,M.E,Ph.D(ELECTROCHEMICAL ENGERY CONVERSION &STORAGE)</option>
<option value="Dr.V.SARANYAN,M.Sc,Ph.D(SURFACE SCIENCE)">Dr.V.SARANYAN,M.Sc,Ph.D(SURFACE SCIENCE)">Dr.V.SARANYAN,M.Sc,Ph.D(SURFACE SCIENCE)">Dr.V.SARANYAN,M.Sc,Ph.D(SURFACE SCIENCE)</option>
<option value="Dr.K.SELVAKUMAR,M.Sc,Ph.D(SURFACE SCIENCE)">Dr.K.SELVAKUMAR,M.Sc,Ph.D(SURFACE SCIENCE)'>Dr.K.SELVAKUMAR,M.Sc,Ph.D(SURFACE SCIENCE)">Dr.K.SELVAKUMAR,M.Sc,Ph.D(SURFACE SCIENCE)</option>
<option value="Dr.V.MURUGAN,B.Phram,M.S.Ph.D(SURFACE SCIENCE)">Dr.V.MURUGAN,B.Phram,M.S.Ph.D(SURFACE SCIENCE)">Dr.V.MURUGAN,B.Phram,M.S.Ph.D(SURFACE SCIENCE)">Dr.V.MURUGAN,B.Phram,M.S.Ph.D(SURFACE SCIENCE)</option>
<option value="Dr.A.SUBBIAH,M.Sc,Ph.D(SURFACE SCIENCE)">Dr.A.SUBBIAH,M.Sc,Ph.D(SURFACE SCIENCE)">Dr.A.SUBBIAH,M.Sc,Ph.D(SURFACE SCIENCE)">Dr.A.SUBBIAH,M.Sc,Ph.D(SURFACE SCIENCE)</option>
<option value="Dr.S.MARUTHAMUTHU,M.Sc,M.Phil,Ph.D(ELECTIVE-II CATHODIC PROTECTION & ELECTROPHRETIC COATINGS)">Dr.S.MARUTHAMUTHU,M.Sc,M.Phil,Ph.D(ELECTIVE-II CATHODIC PROTECTION & ELECTROPHRETIC COATINGS)</option>
<option value="DR.SUNDAR MAYAVAN,B.Tech,M.S,Ph.D(ELECTIVE-II CATHODIC PROTECTION & ELECTROPHRETIC COATINGS)">DR.SUNDAR MAYAVAN,B.Tech,M.S,Ph.D(ELECTIVE-II CATHODIC PROTECTION & ELECTROPHRETIC COATINGS)</option>
<option value="Dr.S.P.MANOHARAN,M.Sc,Ph.D(ELECTIVE-II CATHODIC PROTECTION & ELECTROPHRETIC COATINGS)">Dr.S.P.MANOHARAN,M.Sc,Ph.D(ELECTIVE-II CATHODIC PROTECTION & ELECTROPHRETIC COATINGS)</option>
<option value="Dr.S.SREEJAKUMARI,M.Sc,M.Tech,Ph.D(ELECTIVE-II CATHODIC PROTECTION & ELECTROPHRETIC COATINGS)">Dr.S.SREEJAKUMARI,M.Sc,M.Tech,Ph.D(ELECTIVE-II CATHODIC PROTECTION & ELECTROPHRETIC COATINGS)</option>


        

        </select>
    </td>
</tr>

<tr>
<th>Batch</th>
    <td>
    	<select name="batch" required="required" class="form-control my_form">
            <option value="">batch</option>
            <option value="2016">2016</option>
            <option value="2017">2017</option>
            <option value="2018">2018</option>
            <option value="2019">2019</option>
            <option value="2020">2020</option>
        </select>
    </td>
</tr>
<tr>
	<th>semester</th>
    <td>
    	<select name="semester" required="required" class="form-control my_form">
            <option value="">semester</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
        </select>
    </td>
</tr>
<tr>
	<th>period</th>
    <td>
    	<select name="period" required="required" class="form-control my_form">
            <option value="">period</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
        </select>
    </td>
</tr>
<tr>
	<th>Present</th>
    <td>
    	<select name="atten" class="form-control my_form">
        	<option value="Yes">Yes</option>
            <option value="No">No</option>
        </select>
    </td>
</tr>
<tr>
	<td colspan=2><center>          <input type="submit" value="submit" name="submit" class="my_btn" /></center></td>
</tr>
</table>
	  </form>
    	</div>
    	<div class="col-md-6 ol-sm-6 col-xs-12"></div>
    </div>
   </div>
</div>


<!-- End Content -->

<?php
include('footer.php');
} else{		
	header('location:index.php?suc=suc');	
}
?>
</body>
</html>


Что я уже пробовал:

в db.php

<?php
error_reporting();
$db = new mysqli('localhost', 'root', '', 'cecri karaikudi');
if($db->connect_errno){
	die('Sorry Database not connected !!!');
}
?>

Stefan_Lang

Копирование стены кода-это лень. Если вы, кто знает код лучше всего, не можете потрудиться потратить очень умеренное количество времени, чтобы определить соответствующие строки, которые вызывают эту проблему, то не ожидайте, что кто-то еще потратит значительно большее количество времени, чтобы копаться в вашем коде в поисках довольно неопределенно указанной проблемы!

1 Ответов

Рейтинг:
0

Patrice T

Цитата:
Почему данное значение становится равным 0 при сохранении значения в базе данных

Какая ценность ?
$sql = $db->query("INSERT INTO `daily_atten`(`id`, `roll_no`, `class`, `date`, `subject_name_and_subject_code`, `subject_handle_by`, `batch`, `semester`, `period1`, `present`) VALUES ('$id','$roll_no','$class','$date','$subject_name_and_subject_code','$subject_handle_by','$batch','$semester','$period1','$present')");

Не обязательно решение вашего вопроса, но у вас есть еще одна проблема.
Никогда не создавайте SQL-запрос путем объединения строк. Рано или поздно вы сделаете это с помощью пользовательских вводов, и это откроет дверь к уязвимости под названием "SQL-инъекция", она опасна для вашей базы данных и подвержена ошибкам.
Одна кавычка в имени - и ваша программа выйдет из строя. Если пользователь вводит имя, например "Брайан О'Коннер", может привести к сбою вашего приложения, это уязвимость SQL-инъекции, и сбой-это наименьшая из проблем, вредоносный пользовательский ввод, и он продвигается к командам SQL со всеми учетными данными.
SQL-инъекция - Википедия[^]
SQL-инъекция[^]
Атаки SQL-инъекций на примере[^]
PHP: SQL-инъекция - руководство пользователя[^]
Шпаргалка по предотвращению инъекций SQL - OWASP[^]
Как я могу объяснить SQL-инъекцию без технического жаргона? - Обмен Стеками Информационной Безопасности[^]
[Обновление]
Из вашего комментария: будьте очень осторожны, чтобы использовать существующие переменные
if(isset($_POST['submit'])){
    //print_r($_POST);die;
    $roll = $_POST['roll_no'];
    $name = $_POST['name'];
    $class = $_POST['class'];
    $date = $_POST['date'];
    $subject_name_and_subject_code = $_POST['subject_name_and_subject_code'];
    $subject_handle_by = $_POST['subject_handle_by'];
    $batch=$_POST['batch'];
    $semester=$_POST['semester'];
    $period=$_POST['period'];
    $present = $_POST['atten'];
    // echo "INSERT INTO daily_atten(id, roll_no, class, date, subject_name_and_subject_code, subject_handle_by, batch, semester, period1, present) VALUES ('$roll_no','$class','$date','$subject_name_and_subject_code','$subject_handle_by','$batch','$semester','$period','$present')");
    $sql = $db->query("INSERT INTO `daily_atten`(`id`, `roll_no`, `class`, `date`, `subject_name_and_subject_code`, `subject_handle_by`, `batch`, `semester`, `period1`, `present`) VALUES ('$id','$roll_no','$class','$date','$subject_name_and_subject_code','$subject_handle_by','$batch','$semester','$period1','$present')");


Stefan_Lang

хороший Совет. Однако я не специалист по SQL, и теперь я спрашиваю себя: какова рекомендуемая Альтернатива для составления запроса?

P.S.: ничего страшного, я нашел ответ по четвертой ссылке, которую вы предоставили

На боковой заметке: 5-е звено, похоже, не работает

nehaperiyasamy

в roll_no и period1 я получаю эти значения равны 0

Patrice T

Воспользуйся Улучшить вопрос чтобы обновить ваш вопрос.
Чтобы каждый мог обратить внимание на эту информацию.

Stefan_Lang

Оператор insert использует в качестве значений '$roll_no' и '$period1'. Но вы, похоже, не указали переменные с этими именами, только "$roll " и "$period".