اخواني لقد وضعت الخاصية
enctype="multipart/form-data"
ولقد تم التعديل على الكود
ولقد واجهت مشكلتين
الاولى ...... انه لايسجل اسم الملف الاول في قاعدة البيانات في خانه filename
مع انه تم التاكد من الحقل الاول
كود PHP:
<tr>
<td>ملف</td>
<td><input name="fileanme" type="file" id="fileanme" ></td>
</tr>
وتم التاكد من قاعدة البيانات ان اسم الحقل filename ولكن لايسجل الاسم فقط يرفع الملف الى مجلد upload
ويظهر الرساله في اعلى المتصفح باسم الملف ونوعه وحجمه والرساله هي...
كود PHP:
array ( 'filename' => array ( 'name' => 'habilidoso_HB.wmv', 'type' => 'video/x-ms-wmv', 'tmp_name' => 'C:/camel/tmp\\php41A.tmp', 'error' => 0, 'size' => 1600799, ), 'image' => array ( 'name' => 'نص.txt', 'type' => 'text/plain', 'tmp_name' => 'C:/camel/tmp\\php41B.tmp', 'error' => 0, 'size' => 1789, ), )
هذه هي البيانات التي تسجل في قاعدة البيانات 100% في كود رفع الملف
كود:
$type1 = $_FILES['filename']['type'];
$image = $_FILES['image']['name'];
$type2 = $_FILES['image']['type'];
المشكله الثانيه انه يسجل البيانات مرتين في الجدول qatitle
كود PHP:
$sql="INSERT INTO qatitle (id, author, idauthor, title, info, datatitle, filename, type1, image, type2) VALUES
('', '$author', '$idauthor', '$title','$info', '$timebetx', '$filename', '$type1', '$image', '$type2')";
الكود كامل
كود PHP:
<?php
session_start();
if(!session_is_registered(myusername)){
header("location:../login.php");
}
include('../config.php');
$fullname2=$_SESSION['fullname'] ;
$employeeid2=$_SESSION['employeeid'] ;
if($_GET['action']=="maumt"){
$timebetx=date('Y-m-d H:i:s',time());
$filename = $_FILES['filename']['fiile'];
$type1 = $_FILES['filename']['type'];
$image = $_FILES['image']['name'];
$type2 = $_FILES['image']['type'];
if($_POST["upload"] == "1")
{
$to = "upload/".$_FILES['filename']['name'];
move_uploaded_file($_FILES['filename']['tmp_name'], $to);
$to = "upload/".$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], $to);
$filename=$filename;
$type1=$type1;
$image=$image;
$type2=$type2;
$author=$_POST['author'];
$idauthor=$_POST['idauthor'];
$title=$_POST['title'];
$info=$_POST['info'];
$datatitle=$_POST['datatitle'];
$sql="INSERT INTO qatitle (id, author, idauthor, title, info, datatitle, filename, type1, image, type2) VALUES
('', '$author', '$idauthor', '$title','$info', '$timebetx', '$filename', '$type1', '$image', '$type2')";
mysql_query($sql);
$idsas = mysql_insert_id();
$sql = "UPDATE qatitle SET idtitle = '$idsas' WHERE id = '$idsas'";
mysql_query($sql);
$result=mysql_query($sql) or die(mysql_error());
if($result){
$question=$_POST['question'];
$answer1=$_POST['answer1'];
$choose1=$_POST['choose1'];
$answer2=$_POST['answer2'];
$choose2=$_POST['choose2'];
$answer3=$_POST['answer3'];
$choose3=$_POST['choose3'];
$answer4=$_POST['answer4'];
$choose4=$_POST['choose4'];
$sql2="INSERT INTO qquiz (id, question, idtitle, answer1, choose1, answer2, choose2, answer3, choose3, answer4, choose4) VALUES
('', '$question', '$idsas', '$answer1','$choose1', '$answer2','$choose2','$answer3', '$choose3','$answer4','$choose4')";
$result2=mysql_query($sql2) or die(mysql_error());
if($result2){
}
else {
$result2=mysql_query($sql2) or die(mysql_error());
}
}
else {
echo "<center>خطاء في ادخال البيانات الرجاء الاتصال بالدعم الفني</center>";
}}}
?>
<html dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="content">
<div id="articles">
<div id="left">
<td><form name="maumt" method="post" action="maumt.php?action=maumt"></td>
<td><h2><a href="#">الجدول الاول</a></h2></td>
<br>
<table border="0" width="100%" dir="rtl" >
<tr>
<input name="author" type="hidden" id="author" value="<?php echo $fullname2; ?>"/>
<input name="idauthor" type="hidden" id="idauthor" value="<?php echo $employeeid2; ?>"/>
<tr>
<td>اسم</td>
<td><input name="title" type="text" id="title" ></td>
</tr>
<tr>
<td height="31">ممعلومات</td>
<td rowspan="2"><textarea rows="8" name="info" cols="40" style="color: #000000"></textarea></td>
<tr>
<td></td>
</tr>
</tr>
<tr>
<td>ملف</td>
<td><input name="fileanme" type="file" id="fileanme" ></td>
</tr>
<tr>
<td>صورة</td>
<td><input name="image" type="file" id="image" ></td>
</tr>
<tr>
<td height="30"></td> <td height="30"></td>
</tr>
<tr>
<td colspan="2"><h2><a href="#">ادخال جدول اخر</a></h2></td>
</tr>
<tr>
<td>مكون</td>
<td><input name="question" type="text" id="question" size="40"></td>
</tr>
<tr>
<td>1</td>
<td><input name="choose1" type="text" id="choose1" > <input name="answer1" type="text" id="answer1" size="5" value="0"></td>
</tr>
<tr>
<td>2</td>
<td><input name="choose2" type="text" id="choose2" > <input name="answer2" type="text" id="answer2" size="5" value="0"></td>
</tr>
<tr>
<td>3</td>
<td><input name="choose3" type="text" id="choose3" > <input name="answer3" type="text" id="answer3" size="5" value="0"></td>
</tr>
<tr>
<td>4</td>
<td><input name="choose4" type="text" id="choose4" > <input name="answer4" type="text" id="answer4" size="5" value="0"></td>
</tr>
<tr>
<td height="15"></td>
<td height="15"></td>
</tr>
<tr>
<input type="hidden" name="upload" value="1">
<td><input type="submit" name="Submit" value=" إرسال " ></td>
</tr>
</tr>
</table>
</div>
</body>
</html>