양식을 새로 고침하거나 새로 고침하면 데이터가 사라집니다.페이지 새로 고침 후 데이터가 사라집니다.
public function view_detail()
{
$qry=$this->conn->prepare("SELECT * FROM student_detail WHERE Student_Cnic=:search OR Student_Name=:search");
$qry->bindParam(':search',$this->stsearch);
$qry->execute();
return $qry;
}
내가 데이터
<?php
include 'header.php';
include 'config.php';
include 'classes.php';
$database=new Database();
$db=$database->getConnection();
$gtstu=new stu_sys($db);
if(isset($_POST['stu-view']))
{
$_SESSION['stusearch'] = $_POST['stu-view'];
if(isset($_SESSION['stusearch'])){
$gtstu->stsearch = $_SESSION['stusearch'];
}
}
$fth = $gtstu->view_detail();
?>
<div class="row">
<div class="col-lg-12">
<div class="col-lg-2"></div>
<div class="col-lg-8" style="margin-top: 10%;">
<table class="table table-responsive table-bordered">
<th>Image</th>
<th>Name</th>
<th>Cnic</th>
<th>Department</th>
<th>View Detail</th>
<?php while($row = $fth->fetch(PDO::FETCH_OBJ)):?>
<tr>
<td><img src="images/<?php echo $row->Student_Image; ?>" alt=""/></td>
<td><?php echo $row->Student_Name ?></td>
<td><?php echo $row->Student_Cnic ?></td>
<td><?php echo $row->Deprt ?></td>
<td><a href="#">View More Detail</a></td>
</tr>
<?php endwhile;?>
</table>
<a href="dashboard.php" class="btn btn-primary">Back TO Dashboard</a>
</div>
<div class="col-lg-2"></div>
</div>
</div>
<?php
include 'footer.php'
?>
을 채우는하고 내가 보내고 데이터
<form action="view.php" method="post" id="view_form">
<br>
<label for="">View By Name or CNIC</label>
<input type="text" class="form-control" name="stu-view" id="stu-view" placeholder="Student Name or CNIC"><br>
<input type="submit" name="view-detail" id="view-detail" class="btn btn-success" value="Enroll"><br>
</form>
양식에서 양식 점점 데이터에 대한 나의 질문 ..
양식이 비어있는 이유를 모르겠습니다. 페이지를 새로 고침하면 데이터가 지워집니다.
도움이 되겠습니다.
양식을 제출하면 데이터가 PHP 서버에 제출되고 페이지를 새로 고침하면 데이터가 손실됩니다. 이 목적으로 세션을 사용해야합니다. –
데이터가 채워지는 양식은 간단한 이유 중 하나로 결코 작동하지 않습니다 : 코드 상단에'session_start();'가 포함되어 있지 않습니다. 따라서 페이지 새로 고침시 세션이 삭제됩니다. – icecub
감사합니다 @icecub 나는 페이지에 세션을 추가하는 것을 잊어 버렸습니다. – msz