这里的问题是,当我想提交表单时,它将返回其原始状态(空表单)。表单中有两个部分,用户必须输入输入并上传文件。
这是表格..
<!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" />
<title>Application for Paper Presentation</title>
<script>
function checkFile(grabObj)
{
var sFileName = grabObj.value;
var sFileExt = sFileName.split('.')[sFileName.split('.').length - 1].toLowerCase();
var iFileSize = grabObj.file[0].size;
var iConvert=(iFileSize/1048576).toFixed(2);
if (sFileExt!= "pdf" &&
sFileExt != "doc" &&
sFileExt != "docx") || iFileSize > 1048576)
{
txt="File type : "+ sFileExt +"\n\n";
txt+="Size: " + iConvert + " MB \n\n";
txt+="Please make sure your file is in pdf or doc format and less than 10 MB.\n\n";
alert(txt);
}
}
</script>
</head>
<body><br />
<form action="student_newSubmission.php" method="post" enctype="multipart/form-data">
<center>
<fieldset style="width:500px; background-color: #FFC"><legend align="center" style="font-size:24px">Application for Paper Presentation</legend>
<br>
<?php
$sql=oci_parse($conn,"SELECT * FROM student WHERE matricno='".$_SESSION['id']."'");
$result=oci_execute($sql);
$row=oci_fetch_array($sql,OCI_ASSOC+OCI_RETURN_NULLS);
$stfID=$row['SUPERVISOR'];
$stfID2=$row['COSUPERVISOR'];
//================================
$sql2=oci_parse($conn,"SELECT * FROM staff WHERE staffID='".$stfID."'") or die(oci_error());
$result2=oci_execute($sql2);
$row2=oci_fetch_array($sql2,OCI_ASSOC+OCI_RETURN_NULLS);
$stfname=$row2['STFNAME'];
$sql3=oci_parse($conn,"SELECT * FROM staff WHERE staffID='".$stfID2."'") or die(oci_error());
$result3=oci_execute($sql3);
$row3=oci_fetch_array($sql3,OCI_ASSOC+OCI_RETURN_NULLS);
$stfname2=$row3['STFNAME'];
?>
<table width="1023" cellpadding="2" cellspacing="2">
<tr>
<td width="160"><strong>First Name : </strong></td><td><?php echo $row['FNAME']; ?></td>
<td width="160"><strong>Last Name : </strong></td><td><?php echo $row['LNAME']; ?></td>
</tr>
<tr>
<td><strong>Sponsor : </strong></td><td width="374"><input name="sponsor" type="text" size="50" style="text-transform:uppercase" required value=""></td>
<td><strong>Admission Date : </strong></td><td width="309"><?php echo $row['ADMISSIONDATE']; ?></td>
</tr>
<tr>
<td><strong>Matric No : </strong></td><td width="374"><?php echo $row['MATRICNO']; ?><input type="hidden" name="matricno" value="<?php echo $row['MATRICNO']; ?>" /> </td>
<td><strong>Email Address :</strong></td><td width="309"><?php echo $row['EMAIL']; ?> </td>
</tr>
<tr>
<td><strong>Programme / Sem : </strong></td><td width="374"> <?php echo $row['PROGRAMME']; ?> / <?php echo $row['SEM']; ?>
<td><strong>Phone No.</strong></td><td width="309"><?php echo $row['PHONE']; ?> </td>
</tr>
<tr>
<td width="160"><strong>Field of Study : </strong></td><td colspan="3"><input name="field" type="text" size="140" style="text-transform: uppercase"> </td>
</tr>
<tr>
<td><strong>Supervisor : </strong></td><td width="374"><?php echo $stfname ?></td>
<td><strong>Co-supervisor : </strong></td><td width="309"><?php echo $stfname2; ?></td>
</tr>
</table>
<br />
<fieldset style="width:500px; background-color: #FFC"><legend align="center"> Program Detail </legend>
<table width="833" cellpadding="2" cellspacing="2">
<tr>
<td width="431"><strong> Title of Paper : </strong></td><td width="386"><input name="papertitle" type="text" size="50" style="text-transform: uppercase" required value=""></td>
</tr>
<tr>
<td><strong> Author/ Co. Author : <br />( Please separate using semicolon ' ; ' )</strong></td><td width="386"><textarea name="author" cols="38" rows="3" style="text-transform: uppercase; resize:none" required value=" "></textarea></td>
</tr>
<tr>
<td><strong> Title of Conference : </strong></td><td width="386"><input name="conftitle" type="text" size="50" style="text-transform: uppercase" required value=""></td>
</tr>
<tr>
<td><strong> Organizer : </strong></td><td width="386"><input name="organizer" type="text" size="50" style="text-transform: uppercase"></td>
</tr>
<tr>
<td><strong> Address : </strong></td><td width="386"><textarea name="address" cols="38" id="address" style="text-transform: uppercase; resize:none"></textarea></td>
</tr>
<tr>
<td><strong> Tel/Fax : </strong></td><td width="386"><input name="tel" type="text" size="50"></td>
</tr>
<tr>
<td><strong> Venue : </strong></td><td width="386"><input name="venue" type="text" size="50" style="text-transform: uppercase"></td>
</tr>
<tr>
<td><strong> Date : (dd/mm/YY)</strong></td><td width="386"><input name="confDate" type="text" size="50" style="text-transform: uppercase" ></td>
</tr>
<tr>
<td><strong> Conference / Journal Fees : </strong></td><td width="386"><input name="fee" type="text" size="50" style="text-transform: uppercase"></td>
</tr>
</table>
</fieldset>
<br />
</fieldset>
<br/>
<fieldset style="width:500px; background-color: #FFC"><legend align="center" style="font-size:24px">Upload file</legend>
<p style="color:#F00"> ( Please take note to name your files accordingly and save as .pdf or .doc ) </p>
<table width="809" cellpadding="2" cellspacing="2">
<tr>
<td width="341"><label for="file">Turnitin Similarity Report :</label></td>
<td width="452"><input type="file" name="userfile[]" id="turnitin" onchange="checkFile(this)" required value=""></td>
</tr>
<tr>
<td width="341"><label for="file">Paper Indexing :</label></td>
<td width="452"><input type="file" name="userfile[]" id="paperIndex" onchange="checkFile(this)" > <br />/ Link : <input type="text" name="paperindexurl" size="30" /></td>
</tr>
<tr>
<td width="341"><label for="file">Camera Ready Paper (full) :</label></td>
<td width="452"><input type="file" name="userfile[]" id="cameraReady" onchange="checkFile(this)" required value=""></td>
</tr>
<tr>
<td width="341"><label for="file">Blind Paper (withour author info) :</label></td>
<td width="452"><input type="file" name="userfile[]" id="blindPaper" onchange="checkFile(this)" required value=""></td>
</tr>
<tr><td colspan="2">========================= Extra for Journal Publication =========================</td></tr>
<tr>
<td width="341"><label for="file">Acceptance Letter from Publisher:</label></td>
<td width="452"><input type="file" name="userfile[]" id="acceptLetter" onchange="checkFile(this)"></td>
</tr>
<tr>
<td width="341"><label for="file">Publisher's Reviewers Report :</label></td>
<td width="452"><input type="file" name="userfile[]" id="reviewerReport" onchange="checkFile(this)"></td>
</tr>
<tr>
<td width="341"><label for="file">Paper Submitted Version :</label></td>
<td width="452"><input type="file" name="userfile[]" id="submittedVersion" onchange="checkFile(this)"></td>
</tr>
<tr>
<td width="341"><label for="file">Published Conference Paper :</label></td>
<td width="452">Link : <input type="text" name="confPaperurl" size="30"/></td>
</tr>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input type="hidden" name="submissionDate" required value="<?php echo date("d-M-Y"); ?>" />
</table>
</fieldset><br />
<input type="submit" value="Submit the form" id="submit" align="center">
</center>
</form>
</body>
</html>
这是student_newSubmission.php
<?php
// Inialize session
session_start();
$conn = oci_connect("system","db","localhost/XE")or die(oci_error());
//require_once('connection.php');
?>
<?php
if(isset($_POST['submit']) && !empty($_POST['submit']))
{
$matricNo = $_POST['matricno'];
$submissionDate = $_POST['submissionDate'];
$sponsor = $_POST['sponsor'];
$field = $_POST['field'];
$papertitle = $_POST['papertitle'];
$author = $_POST['author'];
$conftitle = $_POST['conftitle'];
$organizer = $_POST['organizer'];
$address = $_POST['address'];
$tel = $_POST['tel'];
$venue = $_POST['venue'];
$confDate = $_POST['confDate'];
$fee = $_POST['fee'];
$paperIndexUrl = $_POST['paperindexurl'];
$confPaperUrl = $_POST['confPaperurl'];
$query = oci_parse($conn,"INSERT INTO submission(subID, matricNo, submissionDate, sponsor, field, papertitle, author, conftitle, organizer, orgaddress, orgtel, venue, confDate, fee, paperindexurl, confpaperurl) VALUES (seq_subID.nextval, '$matricNo', '$submissionDate', '$sponsor', '$field', '$papertitle', '$author', '$conftitle', '$organizer', '$address', '$tel', '$venue', '$confDate', '$fee', '$paperIndexUrl', '$confPaperUrl')") or die(oci_error());
$exe= oci_execute($query);
if($exe==1)
{
$query2 = oci_parse($conn, "SELECT subID FROM submission WHERE matricNo='".$matricNo."' ORDER BY submissionDate")or die(oci_error());
$exe2 = oci_execute($query2);
$row = oci_fetch_array($query2);
$subID = $row['SUBID'];
}
else
{
echo '<script type="text/javascript">';
echo 'alert("There was an error while uploading your form. Please try again.")';
echo '</script>';
}
if(isset($_POST['submit']) && $_FILES['userfile']['size'] > 0)
{
$count=0;
foreach ($_FILES['userfile']['name'] as $filename)
{
$fileName = $_FILES['userfile']['name'][$count];
$tmpName = $_FILES['userfile']['tmp_name'][$count];
$fileSize = $_FILES['userfile']['size'][$count];
$fileType = $_FILES['userfile']['type'][$count];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$query3 = oci_parse($conn,"INSERT INTO upload (uploadID, uploadname, uploadtype, uploadsize, content, subID) VALUES (seq_uploadID.nextval, '$fileName', '$fileType', '$fileSize', '$content', '$subID')");
$exe3 = oci_execute($query) or die('Error, query failed');
$count=$count + 1;
}
//echo "<br>File $fileName uploaded<br>";
}
if ($exe3 == 1)
{
header('location:homeStudent.php');
echo '<script type="text/javascript">';
echo 'alert ("Successfully submit your form!")';
echo '</script>';
}
else
{
echo '<script type="text/javascript">';
echo 'alert("There was an error while uploading your form. Please try again.")';
echo '</script>';
}
}
?>
我尝试评论文件上传过程并继续进行输入过程..但它仍然无需做任何事情就返回。我希望它可以显示一些错误,所以我可以解决。当它返回空时我也感到空虚。
有人能帮助我吗?我真的不知道如何继续。
答案 0 :(得分:1)
您正在使用if(isset($_POST['submit'])
,而这正在寻找一个按钮named
“提交”,您可以在这里找到:
<input type="submit" value="Submit the form" id="submit" align="center">
应为:
<input type="submit" name="submit" value="Submit the form" id="submit" align="center">
---------------------^^^^^^^^^^^^^
答案 1 :(得分:0)
不能工作。如果我理解你的代码是正确的,你通过$ _POST将数据发送到student_newSubmission.php。然后你通过“标题”找到你的旧页面,但你不发送$ _POST。您必须将数据发送保存到student_newSubmission并将其发送回另一页。每个脚本后都会删除$ _POST,您无法使用它,因此永久保存信息。你必须使用$ _COOKIE或$ _SESSION。