اذهب إلى المحتوى
  • 0

اضافة صورة للطالب

ايمن ميلاد

السؤال

السلام عليكم لدي كود تالي ممكن تعديل عليه ليتم اضافة صورة للطالب 

علم بان حقل اسمه std_img  الذي يتم تخزين صورة به  من نوع text 

 $img_name=$_FILES['file']['name'];
 $img_type = $_FILES['file']['type'];
$img_tmp = $_FILES['file']['tmp_name'];
 $img_dir = '../uploads/';
if(in_array($img_type,array("image/jpeg","image/jpg","image/png","image/gif"))){
			  
					   move_uploaded_file($img_tmp,$img_dir); 

 

 

 

<?php
include('header.php');
?>
<!-------------------------------------------------------------------------------->
<!------------------------------------header-------------------------------------->
<!-------------------------------------------------------------------------------->

<head>
	<!-- مكتبة SweetAlert2 -->
	<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
	<style>
		.rak {
			width: 400px;
			height: 300px;
			font-size: 14px !important;
		}
	</style>

</head>
<div class="col-md-9 pan1">
	<ol class="breadcrumb" style="background-color: #fff;padding-top:8px;padding-bottom:8px;color:#000;font-size:16px;">
		<li><a href="student.php">الطلبة</a></li>
		<li class="active">اضافة طالب جديد</li>
	</ol>
</div>
</div>
<div class="row">
	<?php
	// mysql_query("set character_set_server='utf8'"); 
	// mysql_query("SET NAMES 'utf8'");
	//get subjects data
	//
	$sql3 = mysqli_query($con, "select * from teachers");
	//
	$sql1 = mysqli_query($con, "select * from departments");

	//get student data
	$sql2 = mysqli_query($con, "select * from group_names");

	//get class data
	// $sql3 = mysqli_query($con,"select * from class WHERE `stat`=1");

	?>

	<div class="col-md-9 pan1">
		<div class="panel" style="color:#000;">
			<div class="panel-body" style="font-size:14px; padding-left:40px;padding-right:40px;padding-bottom:25px;padding-top:25px;">
				<form method="POST">
					<div class="form-group" style="margin-top:10px;">
						<label> رقم القيد </label>
						<input name="num_std" type="text" class="form-control" placeholder="قم بكتابة رقم القيد هنا  ">
					</div>
					<div class="form-group" style="margin-top:10px;">
						<label> أسم الطالب </label>
						<input name="name_std" type="text" class="form-control" placeholder=" الرجاء كتابة الاسم كامل ">
					</div>
					<div class="form-group">
						<label>صورة للطالب</label>
						<input type="file" name="file" />
					</div>

					<div class="form-group" style="margin-top:10px;">
						<label> البريد الالكتروني </label>
						<input name="email_STD" type="email" class="form-control" placeholder=" الرجاء كتابة بريد الالكتروني ">
					</div>

					<div class="form-group" style="margin-top:10px;">
						<label> كلمة السر </label>
						<input name="Pass" type="Password" class="form-control" placeholder=" الرجاء كتابة كلمة السر ">
					</div>

					<!------------------------------------------------------------------------------------------------------------------------------->
					<!------------------------------------------------------------------------------------------------------------------------------->

					<div class="form-group" style="margin-top:10px;margin-bottom:25px;">
						<label> القسم </label>
						<select name="dept" class="form-control" style="height: auto;">
							<?php
							while ($row_sub = mysqli_fetch_array($sql1)) {

								echo '<option value="' . $row_sub['id_dept'] . '">' . $row_sub['Name_dept'] . '</option>';
							}
							?>
						</select>
					</div>

					<div class="form-group" style="margin-top:10px;margin-bottom:25px;">
						<label> المشرف </label>
						<select name="teah" class="form-control" style="height: auto;">
							<?php
							while ($row_std = mysqli_fetch_array($sql3)) {

								echo '<option value="' . $row_std['id_teah'] . '">' . $row_std['Name_teah'] . '</option>';
							}
							?>
						</select>
					</div>




					<div class="form-group" style="margin-top:10px;margin-bottom:25px;">
						<label> المجموعة </label>
						<select name="group_ID" class="form-control" style="height: auto;">
							<?php
							while ($row_std = mysqli_fetch_array($sql2)) {

								echo '<option value="' . $row_std['id_group'] . '">' . $row_std['Name_group'] . '</option>';
							}
							?>
						</select>
					</div>

					<!------------------------------------------------------------------------------------------------------------------------------->
					<!------------------------------------------------------------------------------------------------------------------------------->


					<button name="submit" type="submit" class="btn-blue"> إضافة <span class="ion-android-add"></span></button>
					<button type="reset" class="btn-def"> إلغاء <span class="ion-android-delete"></span></button>
				</form>
				<?php
				// mysql_query("set character_set_server='utf8'"); 
				// mysql_query("SET NAMES 'utf8'");

				if (isset($_POST['submit'])) {

					$id_std = $_POST['num_std'];

					$full_name = $_POST['name_std'];

					$dept_std = $_POST['dept'];

					$email_STD = $_POST['email_STD'];

					$pass = $_POST['Pass'];

					$group = $_POST['group_ID'];
					//
					$id_teah = $_POST['teah'];
					//

					if (empty($id_std) or empty($full_name)) {
						echo "<div style='margin-top:10px;' class='text-center alert alert-danger' role='alert'><h3> الرجاء كتابة بيانات صحيحة </h3></div>";
						echo '<meta http-equiv="refresh" content="4;url=student.php" />';
					} else {
						if (filter_var($id_std, FILTER_VALIDATE_INT)) {

							$sql_std = "SELECT * FROM `student` where `Num_std`='$id_std' AND Name_std='$full_name'";
							$query_std = mysqli_query($con, $sql_std);
							$count_std = mysqli_num_rows($query_std);

							if ($count_std == 0) {

								$sql = "INSERT INTO `student`(`Name_std`,  `Num_std`, `Email_STD` , `Password`, `dept_ID`, `group_ID`,`id_teah`) VALUES ( '$full_name' , $id_std , '$email_STD' , '$pass' , $dept_std , $group,$id_teah )";
								// mysql_query("set character_set_server='utf8'"); 
								// mysql_query("set names 'utf8'");
								mysqli_query($con, $sql);
								echo "<script>
								Swal.fire({
									title: 'رسالة تأكيد',
									text: 'تم إضافة بيانات الطالب بنجاح!',
									icon: 'success',
									customClass: 'rak',
								});
								</script>";
								//	echo "<div style='margin-top:10px;'  class='text-center alert alert-success' role='alert'><h3> تم اضافة الطالب بنجاح </h3></div>";
								echo '<meta http-equiv="refresh" content="2;url=student.php" />';
							} else {

								echo "<div style='margin-top:10px;' class='text-center alert alert-danger' role='alert'><h3> هذا الطالب موجود مسبقا </h3></div>";
							}
							//echo $pass;

						} else {
							echo "<div style='margin-top:10px;'  class='text-center alert alert-danger' role='alert'><h3> يجب ان يكون رقم القيد ارقام وليس حروف </h3></div>";
							echo '<meta http-equiv="refresh" content="50;url=student.php" />';
						}
					}
				}

				?>
			</div>
		</div>
	</div>
</div>


<!-------------------------------------------------------------------------------->
<!------------------------------------Footer-------------------------------------->
<!-------------------------------------------------------------------------------->

<?php
include('footer.php');
?>

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

لا توجد أي إجابات على هذا السؤال بعد

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...