0

ここでの問題は、フォームを送信しようとすると、元の状態 (空のフォーム) に戻ってしまうことです。フォームには、ユーザーが入力を入力し、ファイルをアップロードする必要がある 2 つの部分があります。

ここにフォームがあります..

<!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>';
        }
}

?>

ファイルのアップロードプロセスにコメントを付けて、入力プロセスを続行しようとしましたが、何もせずに戻ってきます。エラーが表示されるので、修正できることを願っています。それが空っぽに戻るとき、私もまた空虚に感じます。

誰かが私を助けることができますか?どうすればいいのか本当にわかりません。

4

2 に答える 2

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">
---------------------^^^^^^^^^^^^^
于 2013-11-12T13:12:53.780 に答える