データベースにエントリを挿入する管理者がいて、他の値がデータベースに正しく挿入されていますが、選択オプションの値が挿入されていません。最初に管理者がログインし、彼のセッションはデータベースに新しいエントリを追加した後に開始されます。 助けてください。選択値がデータベースに挿入されていません
私のHTMLフォームがある
<form method="post" action="" enctype="multipart/form-data" role="form">
<div class="col-md-4 form-group">
<label for="SubjectMaterialTitle">Subject Material Title</label>
<input type="text" name="sub_title" placeholder="Subject Material Title" class="form-control" required>
</div>
<div class="col-md-4 form-group">
<label for="Downloadurllink">Download url link</label>
<input type="text" name="sub_url" placeholder="Download url link" class="form-control" required>
</div>
<div class="col-md-4 form-group">
<label for="exampleInputFile">File input</label>
<input type="file" name="sub_file" id="exampleInputFile" required>
<p class="help-block">Upload Image/File upto 2MB size only</p>
</div>
<div class="col-md-4 form-group">
<label for="WritenBy">Writen By</label>
<select class="form-control" name="writen_by">
<?php if(isset($_SESSION['admin_email'])){
echo '<option value='. $_SESSION['admin_username'] .'>'. $_SESSION['admin_username'] .'</option> ';
}
?>
</select>
</div>
</form>
PHPコードは、値が正常にポストされている理由あなたが値arroundの引用符を追加するのを忘れ
<?php
include("includes/config.php");
global $con;
if(isset($_POST['add_submat'])){
//getting the text data from the fields
$sub_title = $_POST['sub_title'];
$sub_url = $_POST['sub_url'];
$writen_by = $_POST['writen_by'];
//getting image from the fields
$sub_file = $_FILES['sub_file']['name'];
$sub_file_tmp = $_FILES['sub_file']['tmp_name'];
move_uploaded_file($sub_file_tmp,"sub-material-files/$sub_file");
//insert data into table
$insert_submat = "insert into m_study_material (sm_title,sm_downloadurl,sm_image,created_by) values ('$sub_title','$sub_url','$sub_file','$writen_by')";
echo $insert_submat;
$run_submat = mysqli_query($con, $insert_submat);
//error_reporting(E_ERROR);
if($run_submat){
echo "<script>alert('Inserted Successfully.')</script>";
} else{
echo "Not inserted";
}
}
?>
すぎデータベース構造をアップロードしてくださいヘルパー関数を利用することができます。または、 'echo $ insert_submat'の結果をコピーしてDBMS Insert Query Executorに貼り付け、ここに結果の画像を投稿してください。 –