Good day ,wish to know how to upload multiple image files with multiple inputs and multiple directories. My code is

    <table border="1px" width="100%"> <tr><td colspan="3" style="background-color:#E8E8E8"><b>Supporting documents upload</b></td></tr> <tr><td> </td><td colspan="3"><input style="height:35px;" type="file" name="pri" required ></td></tr> <tr><td> </td><td colspan="3"><input style="height:35px;" type="file" name="oresult" required ></td></tr> <tr><td> </td><td colspan="3"><input style="height:35px;" type="file" name="oresult2" required ></td></tr> <tr><td> </td><td colspan="3"><input style="height:35px;" type="file" name="dob" required ></td></tr> <table border="1px" width="100%"> <tr><td colspan="3" style="background-color:#E8E8E8"><b>Upload Passport Photograph</b></td></tr> <tr><td> </td><td colspan="3"><input style="height:35px;" type="file" name="photo" required ></td></tr> <tr><td> </td><td colspan="3"><div class="subm" ><input style="font-size:18px; height:45px; font-weight:bold; color:#0033FF" type="submit" style="height:50px" name="submit1" value="Save / Submit Form" ></div></td></tr> </table> </form>

and it connects to

<?php
require 'database.php';
$code_id = $_SESSION['SESS_CODE_NAME'];
 $d = date('D d M Y');
$t = date('h : i : sA');
$uploadDir = 'student_pic/';
$fileName = $_FILES['photo']['name'];
$tmpName = $_FILES['photo']['tmp_name'];
$fileSize = $_FILES['photo']['size'];
$fileType = $_FILES['photo']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file ($tmpName, $filePath);
if (!$result){
echo "error uploading file";
exit;
}
if(!get_magic_quotes_gpc())
{
$fileName = addslashes ($fileName);
$filePath= addslashes ($filePath);
}

$q = mysql_query ("SELECT * FROM studentreg WHERE jamb='$jamb'");
$ja = mysql_fetch_assoc($q);
if ($ja > 0){
echo '
<script type="text/javascript">
alert("This Jamb Number has already been taken")
</script>';

}
else{
$query = "INSERT INTO studentreg (pri, oresult, oresult2, dob, photo) VALUES ('$pri', '$oresult', '$oresult2', '$dob', '$filepath)";

Thank you.

Recommended Answers

All 24 Replies

Member Avatar for diafol

This script of yours. Seems to have been taken from a 10 year old source. You should be able to find newer ones. BTW - sort out the indenting in your code blocks. I'd challenge anybody to read the HTML and for some reason you have js mixed up in your php

So whats d way forward...? thanks

Member Avatar for diafol

Indent your HTML properly so it's readable. Then we can have a look. Also from a cursory glance you seem to have lifted a 10 year old script full of old code. Just sayin.

<table border="1px" width="100%">
       <tr><td colspan="3" style="background-color:#E8E8E8"><b>Supporting documents upload</b></td></tr>

        <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="pri" required ></td></tr>
        <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="oresult" required ></td></tr>
        <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="oresult2" required ></td></tr>       
        <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="dob" required ></td></tr>

<table border="1px" width="100%">
       <tr><td colspan="3" style="background-color:#E8E8E8"><b>Upload Passport Photograph</b></td></tr>

        <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="photo" required ></td></tr>

      <tr><td>&nbsp;</td><td colspan="3"><div class="subm" ><input style="font-size:18px; height:45px; font-weight:bold; color:#0033FF" type="submit" style="height:50px" name="submit1" value="Save / Submit Form" ></div></td></tr>
       </table>
       </form>

i have done that.

Member Avatar for diafol

Not sure, Here's my version:

<table>
  <tr>
    <td colspan="3">Supporting documents upload</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="3"><input type="file" name="pri" required ></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="3"><input type="file" name="oresult" required ></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="3"><input type="file" name="oresult2" required ></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="3"><input type="file" name="dob" required ></td>
  </tr>
  <table>
    <tr>
      <td colspan="3">Upload Passport Photograph</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td colspan="3"><input type="file" name="photo" required ></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td colspan="3">
        <div class="subm" ><input type="submit" name="submit1" value="Save / Submit Form" ></div>
      </td>
    </tr>
  </table>
  </form>

Having taken out all the in-line styling (to be placed in a CSS file). Not usre I understand the nested table or the closing form tag. The nested table isn't set within its own row - so looks wrong.

Try saving the following as test.php and give it a try:

<?php
if( array_key_exists('Submit',$_POST) )
{
    if(!empty($_FILES))
    {
        // these are your "settings"
        $myFiles=Array(  'pri'      => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'pdf;doc;docx', 'label'=>'Pri') 
                        ,'oresult'  => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'pdf;doc;docx', 'label'=>'OResult')
                        ,'oresult2' => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'pdf;doc;docx', 'label'=>'OResult2')
                        ,'dob'      => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'pdf;doc;docx', 'label'=>'DOB')
                        ,'photo'    => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'png;jpg;jpeg;gif', 'label'=>'Photo')
                        );

        //this is where the detected errors will be stored
        $errors=Array();

        foreach($myFiles as $field=>$prop)
        {
            if( array_key_exists($field, $_FILES) )
            {
                // http://php.net/manual/en/features.file-upload.php
                // http://php.net/manual/en/features.file-upload.errors.php
                if( true===$prop['required'] )
                {
                    if($_FILES[$field]['error']===UPLOAD_ERR_NO_FILE)
                    {
                        $errors[] = $prop['label'] . ' is a required field.';
                    }
                    elseif($_FILES[$field]['error']!==UPLOAD_ERR_OK)
                    {
                        $errors[]='File upload for ' . $prop['label'] . ' failed with error code ' . $_FILES[$field]['error'] . '.';
                    }
                }
                elseif($_FILES[$field]['error']!==UPLOAD_ERR_OK)
                {
                    $errors[]='File upload for ' . $prop['label'] . ' failed with error code ' . $_FILES[$field]['error'] . '.';
                }

                if(!empty($errors))
                {
                    break;
                }
                else
                {
                    $prop['destination'] = array_key_exists('destination', $prop) ? $prop['destination'] : getcwd().'/uploads';
                    $prop['destination'] = rtrim($prop['destination']," \t\n\r\0\x0B\/.")

                    if( !is_dir($prop['destination']) )
                    {
                        $errors[] = 'The destination directory for '.$prop['label'].' does not exist.';
                    }
                    else
                    {                   
                        // sanitize filename -- allows only letters, numbers, underscore and periods
                        $_FILES[$field]['name'] = preg_replace('/[^\w\.]/', '', $_FILES[$field]['name']);

                        if( !preg_match('/\w+\.(\w+)$/', $_FILES[$field]['name'],$m) )
                        {
                            $errors[] = 'Invalid file name for ' . $prop['label'] . '.';
                        }
                        else
                        {
                            // check ending file extension
                            $prop['allowed'] = preg_split('/\W+/', strtolower($prop['allowed']), -1, PREG_SPLIT_NO_EMPTY);

                            if( !in_array( strtolower($m[1]), $prop['allowed']) )
                            {
                                $errors[] = 'The attached file type for ' . $prop['label'] . ' is not accepted.';
                            }
                            else
                            {
                                // attempt to move file to final destination 
                                $targetFileName = $prop['destination'] . '/' . $_FILES[$field]['name'];
                                if( !move_uploaded_file($_FILES[$field]['tmp_name'], $targetFileName) )
                                {
                                    $errors[] = 'Unable to move uploaded file for '. $prop['label'];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
    <head>
        <title>Untitled</title>
        <style type="text/css">
        <!--
            thead th{background-color:#E8E8E8;text-align:left;}
        -->
        </style>

    </head>
    <body>
        <?php
        if( !empty($errors) )
        {
            echo '<h2>Errors found:</h2>';
            echo '<ul><li>' . implode('</li><li>',$errors) . '</li></ul>';
        }
        ?>
        <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" enctype="multipart/form-data">
            <table border="1" width="100%">
                <thead>
                    <tr><th colspan="4">Supporting documents upload</th></tr>
                </thead>
                <tbody>
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="pri" required ></td></tr>
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="oresult" required ></td></tr>
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="oresult2" required ></td></tr>       
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="dob" required ></td></tr>
                </tbody>
            </table>
            <table border="1" width="100%">
                <thead>
                    <tr><th colspan="4"><b>Upload Passport Photograph</b></th></tr>
                </thead>
                <tbody>
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="photo" required ></td></tr>
                    <tr><td>&nbsp;</td><td colspan="3"><div class="subm" ><input style="font-size:18px; height:45px; font-weight:bold; color:#0033FF" type="submit" style="height:50px" name="Submit" value="Save / Submit Form" ></div></td></tr>
                </tbody>
            </table>
        </form>
    </body>
</html>

Thank you all.. but i got error on line 44 and there by resulting to Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\rug\reg.php on line 44 @ hielo

@ diafol what about the the script that handles the upload?

Member Avatar for diafol

Sorry sadiq - I don't even know where to start. I'd have to write a script from scratch.
Issues:

GMQ / addslashes - no need with prepared statements
mysql_* functions - deprecated - use PDO/mysqli
Variable assignment from $_FILES items without checking if they exist
Checking name exists - never return '*' - and maybe try COUNT or at least use LIMIT 1 in sql.
You allow the overwriting of a file, but then give the message that the number has been taken - makes no sense.

Anyhow, hope those pointers will help.

but i got error on line 44

On my post above, there is a missing semicolon at the end of line 46:

 ...
 $prop['destination'] = array_key_exists('destination', $prop) ? $prop['destination'] : getcwd().'/uploads';

  // add semicolon at the end of the following line
 $prop['destination'] = rtrim($prop['destination']," \t\n\r\0\x0B\/.");

 if( !is_dir($prop['destination']) )
 ...

Good day @ hielo, Thanks alot... but the files are not moving to its destination folders...After clicking save form, it loads and brings me back to the form with empty inputs..Thanks

...but the files are not moving to its destination folders...

Check your server's error log to see if it gives you a clue as to why it may not be working (ex: permission problem)

After clicking save form, it loads and brings me back to the form with empty inputs...

That was intentional. I don't know what you were expecting, but you can easily add:

elseif( !empty($_FILES)  )
{
    echo '<h1>Thank You</h1>';
}

after line 105.

Thank you...but my server is not saying anything on d error log file...and still its not moving.

It worked fine for me. Did you copy and paste the code above or did you integrate it onto some existing codebase?

I updated the code with the one below so that it will not allow overwriting of existing files. Do a copy-paste onto a new file and try it. If it works, then integrate whatever other code you need onto it.

<?php
//this is where the detected errors will be stored
$errors=Array();

if( array_key_exists('Submit',$_POST) )
{
    if(!empty($_FILES))
    {
        // these are your "settings"
        $myFiles=Array(  'pri'      => Array('required'=>true, 'destination'=>'C:\\Path\\to\\uploads\\directory', 'allowed'=>'pdf;doc;docx', 'label'=>'Pri') 
                        ,'oresult'  => Array('required'=>true, 'destination'=>'C:\\Path\\to\\uploads\\directory', 'allowed'=>'pdf;doc;docx', 'label'=>'OResult')
                        ,'oresult2' => Array('required'=>true, 'destination'=>'C:\\Path\\to\\uploads\\directory', 'allowed'=>'pdf;doc;docx', 'label'=>'OResult2')
                        ,'dob'      => Array('required'=>true, 'destination'=>'C:\\Path\\to\\uploads\\directory', 'allowed'=>'pdf;doc;docx', 'label'=>'DOB')
                        ,'photo'    => Array('required'=>true, 'destination'=>'C:\\Path\\to\\uploads\\directory', 'allowed'=>'png;jpg;jpeg;gif', 'label'=>'Photo')
                        );
        foreach($myFiles as $field=>&$prop)
        {
            $prop['uploaded_file'] = '';        

            if( array_key_exists($field, $_FILES) )
            {                   
                // http://php.net/manual/en/features.file-upload.php
                // http://php.net/manual/en/features.file-upload.errors.php
                if( true===$prop['required'] )
                {
                    if($_FILES[$field]['error']===UPLOAD_ERR_NO_FILE)
                    {
                        $errors[] = $prop['label'] . ' is a required field.';
                    }
                    elseif($_FILES[$field]['error']!==UPLOAD_ERR_OK)
                    {
                        $errors[]='File upload for ' . $prop['label'] . ' failed with error code ' . $_FILES[$field]['error'] . '.';
                    }
                }
                elseif($_FILES[$field]['error']!==UPLOAD_ERR_OK)
                {
                    $errors[]='File upload for ' . $prop['label'] . ' failed with error code ' . $_FILES[$field]['error'] . '.';
                }

                if(!empty($errors))
                {
                    break;
                }
                else
                {
                    $prop['destination'] = array_key_exists('destination', $prop) ? $prop['destination'] : getcwd().'/uploads';
                    $prop['destination'] = str_replace('/',DIRECTORY_SEPARATOR,$prop['destination']);
                    $prop['destination'] = rtrim($prop['destination']," \t\n\r\0\x0B\/.\\");
                    if( !is_dir($prop['destination']) )
                    {
                        $errors[] = 'The destination directory for '.$prop['label'].' does not exist.';
                    }
                    else
                    {                   
                        // sanitize filename -- allows only letters, numbers, underscore and periods
                        $_FILES[$field]['name'] = preg_replace('/[^\w\.]/', '', $_FILES[$field]['name']);
                        if( !preg_match('/\w+\.(\w+)$/', $_FILES[$field]['name'],$m) )
                        {
                            $errors[] = 'Invalid file name for ' . $prop['label'] . '.';
                        }
                        else
                        {
                            // check ending file extension
                            $prop['allowed'] = preg_split('/\W+/', strtolower($prop['allowed']), -1, PREG_SPLIT_NO_EMPTY);
                            if( !in_array( strtolower($m[1]), $prop['allowed']) )
                            {
                                $errors[] = 'The attached file type for ' . $prop['label'] . ' is not accepted.';
                            }
                            else
                            {
                                // attempt to move file to final destination 
                                $targetFileName = $prop['destination'] . DIRECTORY_SEPARATOR  . $_FILES[$field]['name'];

                                if( file_exists($targetFileName) )
                                {
                                    $errors[] = 'The specified file for ' . $field . ' (' . $_FILES[$field]['name'] . ') already exists.';
                                }
                                elseif( !move_uploaded_file($_FILES[$field]['tmp_name'], $targetFileName) )
                                {
                                    $errors[] = 'Unable to move uploaded file for '. $prop['label'];
                                }
                                else
                                {
                                    $prop['uploaded_file'] = $targetFileName;
                                }
                            }
                        }
                    }
                }
            }
        }

        if( !empty($errors) )
        {
            foreach($myFiles as $field=>$prop)
            {
                if(!empty($prop['uploaded_file']) && file_exists($prop['uploaded_file']) )
                {
                    unlink($prop['uploaded_file']);
                }
            }
        }
        else
        {
            # insert into db here
        }
    }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Untitled</title>
        <style type="text/css">
        <!--
            thead th{background-color:#E8E8E8;text-align:left;}
        -->
        </style>
    </head>
    <body>
        <?php
        if( !empty($errors) )
        {
            echo '<h2>Errors found:</h2>';
            echo '<ul><li>' . implode('</li><li>',$errors) . '</li></ul>';
        }
        elseif( !empty($_FILES)  )
        {
            echo '<h1>Thank You</h1>';
        }
        ?>
        <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" enctype="multipart/form-data">
            <table border="1" width="100%">
                <thead>
                    <tr><th colspan="4">Supporting documents upload</th></tr>
                </thead>
                <tbody>
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="pri" required ></td></tr>
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="oresult" required ></td></tr>
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="oresult2" required ></td></tr>       
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="dob" required ></td></tr>
                </tbody>
            </table>
            <table border="1" width="100%">
                <thead>
                    <tr><th colspan="4"><b>Upload Passport Photograph</b></th></tr>
                </thead>
                <tbody>
                    <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="photo" required ></td></tr>
                    <tr><td>&nbsp;</td><td colspan="3"><div class="subm" ><input style="font-size:18px; height:45px; font-weight:bold; color:#0033FF" type="submit" style="height:50px" name="Submit" value="Save / Submit Form" ></div></td></tr>
                </tbody>
            </table>
        </form>
    </body>
</html>

This is the final code: Please help me inspect it. Thanks

<?php
session_start();
require 'database.php';
$code_id = $_SESSION['SESS_CODE_NAME'];
$sco = mysql_query ("SELECT * FROM regcode WHERE code = '$code_id'");
$row = mysql_fetch_assoc($sco);
if ($row['status'] == "used"){
header("location:index.php");
}
?>
<?php
if (isset($_POST['submit'])){
$surname = $_POST['surname'];
$othernames = $_POST['othernames'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$religion = $_POST['religion'];
$country = $_POST['country'];
$state = $_POST['state'];
$city = $_POST['city'];
$date = $_POST['day'].' '.$_POST['month'].' '.$_POST['year'];
$hobby = $_POST['hobby'];
$lang = $_POST['lang'];

$school = $_POST['school'];
$programme = $_POST['programme'];
$course = $_POST['course'];
$type1 = $_POST['type1'];
$sitting1 = $_POST['sitting1'];
$regno1 = $_POST['regno1'];

$sub1 = $_POST['sub1'];
$grade1 = $_POST['grade1'];
$sub2 = $_POST['sub2'];
$grade2 = $_POST['grade2'];
$sub3 = $_POST['sub3'];
$grade3 = $_POST['grade3'];
$sub4 = $_POST['sub4'];
$grade4 = $_POST['grade4'];
$sub5 = $_POST['sub5'];
$grade5 = $_POST['grade5'];
$sub6 = $_POST['sub6'];
$grade6 = $_POST['grade6'];
$sub7 = $_POST['sub7'];
$grade7 = $_POST['grade7'];
$sub8 = $_POST['sub8'];
$grade8 = $_POST['grade8'];
$sub9 = $_POST['sub9'];
$grade9 = $_POST['grade9'];
$sub10 = $_POST['sub10'];
$grade10 = $_POST['grade10'];
$sub11 = $_POST['sub11'];
$grade11 = $_POST['grade11'];
$sub12 = $_POST['sub12'];
$grade12 = $_POST['grade12'];
$sub13 = $_POST['sub13'];
$grade13 = $_POST['grade13'];
$sub14 = $_POST['sub14'];
$grade14 = $_POST['grade14'];
$sub15 = $_POST['sub15'];
$grade15 = $_POST['grade15'];
$sub16 = $_POST['sub16'];
$grade16 = $_POST['grade16'];
$sub17 = $_POST['sub17'];
$grade17 = $_POST['grade17'];
$sub18 = $_POST['sub18'];
$grade18 = $_POST['grade18'];

}

?>
<?php
include 'register.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Student Registration Portal</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css1/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css1/layout.css" type="text/css" media="all">
<link rel="stylesheet" href="css1/style.css" type="text/css" media="all">
<style type="text/css">
table tr td{border-top:1px dashed #999999; border-bottom:1px dashed #999999; padding:10px; color:black; font-size:18px;}
input{width:360px; border:1px solid #CCCCCC; padding:4px; height:20px;}
input:hover{width:360px; border:1px solid #0066FF; padding:4px; height:20px;}
select{width:130px; border:1px solid #CCCCCC; padding:4px; height:35px;}
.loc select{width:170px; border:1px solid #CCCCCC; padding:4px; height:35px;}
.loc1 select{width:120px;}
.loc2 select{width:73px;}
.loca select{width:250px;}
.loca1 select{width:80px;}
.subm input:hover{ box-shadow:none;}
.reco select{width:330px;}

</style>

<!--[if lt IE 9]>
<script type="text/javascript" src="js/ie6_script_other.js"></script>
<script type="text/javascript" src="js/html5.js"></script>
<![endif]-->
</head>
<body id="page1">
<!-- START PAGE SOURCE -->
<div class="body3"></div>
<div class="body1">
  <div class="main">
    <header>
      <div id="logo_box">
        <h1><a href="#" id="logo">UNIVERSITY OF MAIDUGURI, BORNO STATE<span> Remedial Registration Portal</span></a></h1>
      </div>
      <nav>
        <ul id="menu">
          <li id="menu_active"><a href="../logout.php">Home</a></li>
        </ul>
      </nav>
      <div class="wrapper">
        <div class="text1">Confirmation / Upload Page</div>
        <div class="text2">2015/2016 Admission <?php echo $code_id; ?></div>

      </div>
    </header>
  </div>
</div>
<div class="body2">
  <div class="main">
    <section id="content">
      <div class="marg_top wrapper">


      </div>
      <div class="wrapper marg_top2">

        <article class="col2 pad_left1">
          <div class="pad">
            <h2>Student Registration</h2>
           <div style="font-size:20px;">
           <form action="regconfirm.php" method="post" enctype="multipart/form-data">
           <table border="1px" width="100%">
           <tr><td colspan="2" style="background-color:#E8E8E8"><b>Student Bio Data</b></td></tr>
           <tr><td width="150px">Surname</td><td><input type="text" name="surname" placeholder="Your Surname" value="<?php echo $surname; ?>" required><input type="hidden" name="appno" value="<?php echo $code_id;?>"></td></tr>
           <tr><td>Other Names</td><td><input type="text" name="othernames" placeholder="Your Othernames" value="<?php echo $othernames; ?>" required></td></tr>
           <tr><td width="150px">Address</td><td><input type="text" name="address" placeholder="Your Address" value="<?php echo $address; ?>" required></td></tr
           ><tr><td width="150px">Address 2</td><td><input type="text" name="address2" placeholder="Alternative Address" value="<?php echo $address2; ?>" required></td></tr>           
           <tr><td>Phone</td><td><input type="text" name="phone" placeholder="Your Phone Number" value="<?php echo $phone; ?>" required></td></tr>
           <tr><td>E-mail</td><td><input type="email" name="email" placeholder="Your E-mail" value="<?php echo $email; ?>" required></td></tr>
           <tr><td>Languages Spoken</td><td><input type="text" name="lang" placeholder="Languages Spoken" value="<?php echo $lang; ?>" required></td></tr>             

            <table border="1px" width="100%">
    <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="10px">  <select name="gender" required><option selected="selected" ><?php echo $gender; ?></option>
           <option  value="Male">Male</option>
           <option value="Female">Female</option></select></td><td>

           <select name="religion" required><option selected="selected"required><?php echo $religion; ?></option>
           <option  value="Christian">Christian</option>
           <option value="Muslim">Muslim</option></select> </td></tr>
    <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>




    </td></tr>

    <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>

           </td><td>


       </td></tr>


     <table border="1px" width="100%">
           <tr><td colspan="2" style="background-color:#E8E8E8"><b>Course of Choice</b></td></tr>
           <tr><td width="150px">School</td><td>
           <div class="reco">
           <select name="school" required><option selected="selected"><?php echo $school ?></option>
           <option  value="School of remedial studies">School of remedial studies</option></select>
           </div>
           </td></tr>
           <tr><td>Programme</td><td>
           <div class="reco">
           <select name="programme" required><option selected="selected"required><?php echo $programme ?></option>
           <option  value="Remedial Art Programme">Remedial Art Programmes</option>
           <option  value="Remedial Science Programme">Remedial Science Programme</option>
                   </select>
                   </div>
           </td></tr>
           <tr><td width="150px">Course</td><td>
           <div class="reco">
           <select name="course" required><option selected="selected"required><?php echo $course ?></option>
           <option  value="Computer Engineering">Computer Engineering</option>
           <option  value="Computer Science">Computer Science</option>
           <option  value="Mass Coomunication">Mass Coomunication</option>
                   </select>
                   </div>
          </td></tr>


    <table border="1px" width="100%">
           <tr><td colspan="3" style="background-color:#E8E8E8"><b>O, Level I Details</b></td></tr>
           <tr><td width="150px">Type</td><td colspan="2">
           <select name="type1" required><option selected="selected"required><?php echo $type1 ?></option>
           <option  value="WASSCE">WASSCE</option>
            <option  value="NECO">NECO</option>
            <option  value="NABTEB">NABTEB</option>
            <option  value="GCE WAEC">GCE (WAEC)</option>
            <option  value="GCE NECO">GCE (NECO)</option>
           </select>
           </td></tr>
           <tr><td width="150px">Sittings</td><td colspan="2">
           <select name="sitting1" required><option selected="selected"required><?php echo $sitting1 ?></option>
           <option  value="1st Sitting">1st Sitting</option>
            <option value="2st Sitting">2st Sitting</option>
               <tr><td>Reg/exam no.</td><td colspan="2"><input type="text" name="regno1" value="<?php echo $regno1;?>" required></td></tr>
           <tr><td rowspan="9"><br><br><br><br>O,Level Subjects</td><td>
           <div class="loca">
           <select name="sub1" required><option selected="selected"required><?php echo $sub1 ?></option>
           <option  value="English Language">English Language</option>
           <option  value="Mathematics">Mathematics</option>
           <option  value="Economics">Economics</option>
            <option  value="Biology">Biology</option>
           <option  value="Civic Education">Civic Education</option>
           <option  value="Agricultural Science">Agricultural Science</option>
            <option  value="Computer Studies">Computer Studies</option>
           <option  value="Geography">Geography</option>
           <option  value="Lit-in-English">Lit-in-English</option>
            <option  value="Government">Government</option>
           <option  value="Christian Religion Studies">Christian Religion Studies</option>
           <option  value="Islamic Religion Studies">Islamic Religion Studies</option>
            <option  value="Commerce">Commerce</option>
           <option  value="Financial Accounting">Financial Accounting</option>
           <option  value="Physics">Physics</option>
           <option  value="Chemistry">Chemistry</option>
            <option  value="Further Mathematics">Further Mathematics</option>
           <option  value="Yoruba">Yoruba</option>


                   </select></div>
          </td><td><input style="width:70px" type="text" name="grade18" value="<?php echo $grade18 ?>" required>
           </td></tr>
    <table border="1px" width="100%">
           <tr><td colspan="3" style="background-color:#E8E8E8"><b>Supporting documents upload</b></td></tr>

            <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="pri" required ></td></tr>
            <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="oresult" required ></td></tr>
            <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="oresult2" required ></td></tr>       
            <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="dob" required ></td></tr>

    <table border="1px" width="100%">
           <tr><td colspan="3" style="background-color:#E8E8E8"><b>Upload Passport Photograph</b></td></tr>

            <tr><td>&nbsp;</td><td colspan="3"><input style="height:35px;" type="file" name="photo" required ></td></tr>

          <tr><td>&nbsp;</td><td colspan="3"><div class="subm" ><input style="font-size:18px; height:45px; font-weight:bold; color:#0033FF" type="submit" style="height:50px" name="submit1" value="Save / Submit Form" ></div></td></tr>
           </table>
           </form>


       </div>
          </div>
        </article>
      </div>
    </section>
  </div>
</div>
<div class="main">
  <footer>
    <div class="wrapper">

      <article class="col2 pad_left1">
        <div class="pad">
          <div class="wrapper">


          </div>
        </div>
      </article>
    </div>
    <div class="under2"></div>
    <div class="footerlink">
      <p class="lf" style="font-size:15px;">Copyright &copy; <?php echo date('Y');?> <a href="#">RUGIPO Online Entrance Examination</a> - All Rights Reserved</p>

    </div>
  </footer>
</div>
</body>
</html>

This is what the file connects to..Thanks..Please pardon my porous code..Thanks

<?php
require 'database.php';
$code_id = $_SESSION['SESS_CODE_NAME'];
 $d = date('D d M Y');
$t = date('h : i : sA');
if(isset($_POST['submit1'])){
$surname = $_POST['surname'];
$othernames = $_POST['othernames'];
$gender = $_POST['gender'];
$religion = $_POST['religion'];
$date = $_POST['bday'];
$state = $_POST['state'];
$city = $_POST['city'];
$country = $_POST['country'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$lang = $_POST['lang'];
$hobby = $_POST['hobby'];
$school = $_POST['school'];
$programme = $_POST['programme'];
$course = $_POST['course'];
$type1 = $_POST['type1'];
$sitting1 = $_POST['sitting1'];
$regno1 = $_POST['regno1'];
$type2 = $_POST['type2'];
$sitting2 = $_POST['sitting2'];
$regno2 = $_POST['regno2'];
$sub1 = $_POST['sub1'];
$grade1 = $_POST['grade1'];
$sub2 = $_POST['sub2'];
$grade2 = $_POST['grade2'];
$sub3 = $_POST['sub3'];
$grade3 = $_POST['grade3'];
$sub4 = $_POST['sub4'];
$grade4 = $_POST['grade4'];
$sub5 = $_POST['sub5'];
$grade5 = $_POST['grade5'];
$sub6 = $_POST['sub6'];
$grade6 = $_POST['grade6'];
$sub7 = $_POST['sub7'];
$grade7 = $_POST['grade7'];
$sub8 = $_POST['sub8'];
$grade8 = $_POST['grade8'];
$sub9 = $_POST['sub9'];
$grade9 = $_POST['grade9'];
$sub10 = $_POST['sub10'];
$grade10 = $_POST['grade10'];
$sub11 = $_POST['sub11'];
$grade11 = $_POST['grade11'];
$sub12 = $_POST['sub12'];
$grade12 = $_POST['grade12'];
$sub13 = $_POST['sub13'];
$grade13 = $_POST['grade13'];
$sub14 = $_POST['sub14'];
$grade14 = $_POST['grad14'];
$sub15 = $_POST['sub15'];
$grade15 = $_POST['grade15'];
$sub16 = $_POST['sub16'];
$grade16 = $_POST['grade16'];
$sub17 = $_POST['sub17'];
$grade17 = $_POST['grade17'];
$sub18 = $_POST['sub18'];
$grade18 = $_POST['grade18'];
$pri = $_POST['pri'];
$oresult = $_POST['oresult'];
$oresult2 = $_POST['oresult2'];
$dob = $_POST['dob'];
$photo = $_POST['filepath'];
$total = $grade1 + $grade2 + $grade3 + $grade4;
$appno = $_POST['appno'];
$date = $d .' '.$t;
$time = "inactive";
$status = "undone";
$examdate = "Admission processing in progress...";
    $errors=Array();
    if( array_key_exists('Submit',$_POST) )
    {
        if(!empty($_FILES))
        {
            // these are your "settings"
            $myFiles=Array(  'pri_m'      => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'pdf;doc;docx', 'label'=>'pri') 
                            ,'o_level'  => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'pdf;doc;docx', 'label'=>'oresult')
                            ,'o_level2' => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'pdf;doc;docx', 'label'=>'oresult2')
                            ,'do_b'      => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'pdf;doc;docx', 'label'=>'dob')
                            ,'student_pic'    => Array('required'=>true, 'destination'=>'/path/to/save/directory/', 'allowed'=>'png;jpg;jpeg;gif', 'label'=>'photo')
                            );
            foreach($myFiles as $field=>&$prop)
            {
                $prop['uploaded_file'] = '';        
                if( array_key_exists($field, $_FILES) )
                {                   
                    // http://php.net/manual/en/features.file-upload.php
                    // http://php.net/manual/en/features.file-upload.errors.php
                    if( true===$prop['required'] )
                    {
                        if($_FILES[$field]['error']===UPLOAD_ERR_NO_FILE)
                        {
                            $errors[] = $prop['label'] . ' is a required field.';
                        }
                        elseif($_FILES[$field]['error']!==UPLOAD_ERR_OK)
                        {
                            $errors[]='File upload for ' . $prop['label'] . ' failed with error code ' . $_FILES[$field]['error'] . '.';
                        }
                    }
                    elseif($_FILES[$field]['error']!==UPLOAD_ERR_OK)
                    {
                        $errors[]='File upload for ' . $prop['label'] . ' failed with error code ' . $_FILES[$field]['error'] . '.';
                    }
                    if(!empty($errors))
                    {
                        break;
                    }
                    else
                    {
                        $prop['destination'] = array_key_exists('destination', $prop) ? $prop['destination'] : getcwd().'/uploads';
                        $prop['destination'] = str_replace('/',DIRECTORY_SEPARATOR,$prop['destination']);
                        $prop['destination'] = rtrim($prop['destination']," \t\n\r\0\x0B\/.\\");
                        if( !is_dir($prop['destination']) )
                        {
                            $errors[] = 'The destination directory for '.$prop['label'].' does not exist.';
                        }
                        else
                        {                   
                            // sanitize filename -- allows only letters, numbers, underscore and periods
                            $_FILES[$field]['name'] = preg_replace('/[^\w\.]/', '', $_FILES[$field]['name']);
                            if( !preg_match('/\w+\.(\w+)$/', $_FILES[$field]['name'],$m) )
                            {
                                $errors[] = 'Invalid file name for ' . $prop['label'] . '.';
                            }
                            else
                            {
                                // check ending file extension
                                $prop['allowed'] = preg_split('/\W+/', strtolower($prop['allowed']), -1, PREG_SPLIT_NO_EMPTY);
                                if( !in_array( strtolower($m[1]), $prop['allowed']) )
                                {
                                    $errors[] = 'The attached file type for ' . $prop['label'] . ' is not accepted.';
                                }
                                else
                                {
                                    // attempt to move file to final destination 
                                    $targetFileName = $prop['destination'] . DIRECTORY_SEPARATOR  . $_FILES[$field]['name'];
                                    if( file_exists($targetFileName) )
                                    {
                                        $errors[] = 'The specified file for ' . $field . ' (' . $_FILES[$field]['name'] . ') already exists.';
                                    }
                                    elseif( !move_uploaded_file($_FILES[$field]['tmp_name'], $targetFileName) )
                                    {
                                        $errors[] = 'Unable to move uploaded file for '. $prop['label'];
                                    }
                                    else
                                    {
                                        $prop['uploaded_file'] = $targetFileName;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if( !empty($errors) )
            {
                foreach($myFiles as $field=>$prop)
                {
                    if(!empty($prop['uploaded_file']) && file_exists($prop['uploaded_file']) )
                    {
                        unlink($prop['uploaded_file']);
                    }
                }
            }
        }
    }
$q = mysql_query ("SELECT * FROM studentreg WHERE jamb='$jamb'");
$ja = mysql_fetch_assoc($q);
if ($ja > 0){
echo '
<script type="text/javascript">
alert("This Jamb Number has already been taken")
</script>';
}
else{
$query = "INSERT INTO studentreg (surname, othernames, gender, religion, bday, state, city, country, email, phone, address, address2, hobby, lang, school, programme, course, type1, sitting1, regno1, type2, sitting2, regno2, sub1, grade1, sub2, grade2, sub3, grade3, sub4, grade4, sub5, grade5, sub6, grade6, sub7, grade7, sub8, grade8, sub9, grade9, sub10, grade10, sub11, grade11, sub12, grade12, sub13, grade13, sub14, grade14, sub15, grade15, sub16, grade16, sub17, grade17, sub18, grade18, pri, oresult, oresult2, dob, photo, total, appno, date, time, status, examdate, photo) VALUES ('$surname', '$othernames', '$gender', '$religion', '$date', '$state', '$city', '$country', '$email', '$phone', '$address', '$address2', '$hobby', '$lang', '$school', '$programme', '$course', '$type1', '$sitting1', '$regno1', '$type2', '$sitting2', '$regno2', '$sub1', '$grade1', '$sub2', '$grade2', '$sub3', '$grade3', '$sub4', '$grade4', '$sub5', '$grade5', '$sub6', '$grade6', '$sub7', '$grade7', '$sub8', '$grade8', '$sub9', '$grade9', '$sub10', '$grade10', '$sub11', '$grade11', '$sub12', '$grade12', '$sub13', '$grade13', '$sub14', '$grade14', '$sub15', '$grade15', '$sub16', '$grade16', '$sub17', '$grade17', '$sub18', '$grade18', '$pri', '$oresult', '$oresult2', '$dob', '$filePath', '$total', '$appno', '$date', '$time', '$status', '$examdate')";

$sqli = mysql_query ("UPDATE regcode SET status = 'used' WHERE code = '$code_id'");

if ($query){
 header("Location:student_form.php");

}

mysql_query($query) or die ('Error, query failed');

mysql_close();
}


}


?>

On submit button on your first form has name="submit1", so you need to update line 78 to test for 'submit1' instead of 'Submit'. Also, on lines 83-87 you need to update'destination'=>'/path/to/save/directory/' with the actual location of the directory where the files are to be saved.

Sir Hielo, Please help me cross check the file...Its not sending the form information to the database...Thanks as i await your usual warm rersponse..Thanks... The final code is below..

<?php
require 'database.php';
$code_id = $_SESSION['SESS_CODE_NAME'];
 $d = date('D d M Y');
$t = date('h : i : sA');
if(isset($_POST['submit1'])){
$surname = $_POST['surname'];
$othernames = $_POST['othernames'];
$gender = $_POST['gender'];
$religion = $_POST['religion'];
$date = $_POST['bday'];
$state = $_POST['state'];
$city = $_POST['city'];
$country = $_POST['country'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$lang = $_POST['lang'];
$hobby = $_POST['hobby'];
$school = $_POST['school'];
$programme = $_POST['programme'];
$course = $_POST['course'];
$type1 = $_POST['type1'];
$sitting1 = $_POST['sitting1'];
$regno1 = $_POST['regno1'];
$type2 = $_POST['type2'];
$sitting2 = $_POST['sitting2'];
$regno2 = $_POST['regno2'];
$sub1 = $_POST['sub1'];
$grade1 = $_POST['grade1'];
$sub2 = $_POST['sub2'];
$grade2 = $_POST['grade2'];
$sub3 = $_POST['sub3'];
$grade3 = $_POST['grade3'];
$sub4 = $_POST['sub4'];
$grade4 = $_POST['grade4'];
$sub5 = $_POST['sub5'];
$grade5 = $_POST['grade5'];
$sub6 = $_POST['sub6'];
$grade6 = $_POST['grade6'];
$sub7 = $_POST['sub7'];
$grade7 = $_POST['grade7'];
$sub8 = $_POST['sub8'];
$grade8 = $_POST['grade8'];
$sub9 = $_POST['sub9'];
$grade9 = $_POST['grade9'];
$sub10 = $_POST['sub10'];
$grade10 = $_POST['grade10'];
$sub11 = $_POST['sub11'];
$grade11 = $_POST['grade11'];
$sub12 = $_POST['sub12'];
$grade12 = $_POST['grade12'];
$sub13 = $_POST['sub13'];
$grade13 = $_POST['grade13'];
$sub14 = $_POST['sub14'];
$grade14 = $_POST['grad14'];
$sub15 = $_POST['sub15'];
$grade15 = $_POST['grade15'];
$sub16 = $_POST['sub16'];
$grade16 = $_POST['grade16'];
$sub17 = $_POST['sub17'];
$grade17 = $_POST['grade17'];
$sub18 = $_POST['sub18'];
$grade18 = $_POST['grade18'];
$pri = $_POST['pri'];
$oresult = $_POST['oresult'];
$oresult2 = $_POST['oresult2'];
$dob = $_POST['dob'];
$photo = $_POST['filepath'];
$total = $grade1 + $grade2 + $grade3 + $grade4;
$appno = $_POST['appno'];
$date = $d .' '.$t;
$time = "inactive";
$status = "undone";
$examdate = "Admission processing in progress...";
    $errors=Array();
    if( array_key_exists('Submit1',$_POST) )
    {
        if(!empty($_FILES))
        {
            // these are your "settings"
        $myFiles=Array(  'pri'      => Array('required'=>true, 'destination'=>'pri_m', 'allowed'=>'pdf;doc;docx', 'label'=>'pri_m') 
                        ,'oresult'  => Array('required'=>true, 'destination'=>'oresult', 'allowed'=>'pdf;doc;docx', 'label'=>'oresult')
                        ,'oresult2' => Array('required'=>true, 'destination'=>'oresult2', 'allowed'=>'pdf;doc;docx', 'label'=>'oresult2')
                        ,'dob'      => Array('required'=>true, 'destination'=>'dob', 'allowed'=>'pdf;doc;docx', 'label'=>'dob')
                        ,'photo'    => Array('required'=>true, 'destination'=>'student_pic', 'allowed'=>'png;jpg;jpeg;gif', 'label'=>'Photo')                            );
            foreach($myFiles as $field=>&$prop)
            {
                $prop['uploaded_file'] = '';        
                if( array_key_exists($field, $_FILES) )
                {                   
                    // http://php.net/manual/en/features.file-upload.php
                    // http://php.net/manual/en/features.file-upload.errors.php
                    if( true===$prop['required'] )
                    {
                        if($_FILES[$field]['error']===UPLOAD_ERR_NO_FILE)
                        {
                            $errors[] = $prop['label'] . ' is a required field.';
                        }
                        elseif($_FILES[$field]['error']!==UPLOAD_ERR_OK)
                        {
                            $errors[]='File upload for ' . $prop['label'] . ' failed with error code ' . $_FILES[$field]['error'] . '.';
                        }
                    }
                    elseif($_FILES[$field]['error']!==UPLOAD_ERR_OK)
                    {
                        $errors[]='File upload for ' . $prop['label'] . ' failed with error code ' . $_FILES[$field]['error'] . '.';
                    }
                    if(!empty($errors))
                    {
                        break;
                    }
                    else
                    {
                        $prop['destination'] = array_key_exists('destination', $prop) ? $prop['destination'] : getcwd().'/uploads';
                        $prop['destination'] = str_replace('/',DIRECTORY_SEPARATOR,$prop['destination']);
                        $prop['destination'] = rtrim($prop['destination']," \t\n\r\0\x0B\/.\\");
                        if( !is_dir($prop['destination']) )
                        {
                            $errors[] = 'The destination directory for '.$prop['label'].' does not exist.';
                        }
                        else
                        {                   
                            // sanitize filename -- allows only letters, numbers, underscore and periods
                            $_FILES[$field]['name'] = preg_replace('/[^\w\.]/', '', $_FILES[$field]['name']);
                            if( !preg_match('/\w+\.(\w+)$/', $_FILES[$field]['name'],$m) )
                            {
                                $errors[] = 'Invalid file name for ' . $prop['label'] . '.';
                            }
                            else
                            {
                                // check ending file extension
                                $prop['allowed'] = preg_split('/\W+/', strtolower($prop['allowed']), -1, PREG_SPLIT_NO_EMPTY);
                                if( !in_array( strtolower($m[1]), $prop['allowed']) )
                                {
                                    $errors[] = 'The attached file type for ' . $prop['label'] . ' is not accepted.';
                                }
                                else
                                {
                                    // attempt to move file to final destination 
                                    $targetFileName = $prop['destination'] . DIRECTORY_SEPARATOR  . $_FILES[$field]['name'];
                                    if( file_exists($targetFileName) )
                                    {
                                        $errors[] = 'The specified file for ' . $field . ' (' . $_FILES[$field]['name'] . ') already exists.';
                                    }
                                    elseif( !move_uploaded_file($_FILES[$field]['tmp_name'], $targetFileName) )
                                    {
                                        $errors[] = 'Unable to move uploaded file for '. $prop['label'];
                                    }
                                    else
                                    {
                                        $prop['uploaded_file'] = $targetFileName;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if( !empty($errors) )
            {
                foreach($myFiles as $field=>$prop)
                {
                    if(!empty($prop['uploaded_file']) && file_exists($prop['uploaded_file']) )
                    {
                        unlink($prop['uploaded_file']);
                    }
                }
            }
        }
    }
$q = mysql_query ("SELECT * FROM studentreg WHERE jamb='$jamb'");
$ja = mysql_fetch_assoc($q);
if ($ja > 0){
echo '
<script type="text/javascript">
alert("This Jamb Number has already been taken")
</script>';
}
else{
$query = "INSERT INTO studentreg (surname, othernames, gender, religion, bday, state, city, country, email, phone, address, address2, hobby, lang, school, programme, course, type1, sitting1, regno1, type2, sitting2, regno2, sub1, grade1, sub2, grade2, sub3, grade3, sub4, grade4, sub5, grade5, sub6, grade6, sub7, grade7, sub8, grade8, sub9, grade9, sub10, grade10, sub11, grade11, sub12, grade12, sub13, grade13, sub14, grade14, sub15, grade15, sub16, grade16, sub17, grade17, sub18, grade18, pri, oresult, oresult2, dob, photo, total, appno, date, time, status, examdate, photo) VALUES ('$surname', '$othernames', '$gender', '$religion', '$date', '$state', '$city', '$country', '$email', '$phone', '$address', '$address2', '$hobby', '$lang', '$school', '$programme', '$course', '$type1', '$sitting1', '$regno1', '$type2', '$sitting2', '$regno2', '$sub1', '$grade1', '$sub2', '$grade2', '$sub3', '$grade3', '$sub4', '$grade4', '$sub5', '$grade5', '$sub6', '$grade6', '$sub7', '$grade7', '$sub8', '$grade8', '$sub9', '$grade9', '$sub10', '$grade10', '$sub11', '$grade11', '$sub12', '$grade12', '$sub13', '$grade13', '$sub14', '$grade14', '$sub15', '$grade15', '$sub16', '$grade16', '$sub17', '$grade17', '$sub18', '$grade18', '$pri', '$oresult', '$oresult2', '$dob', '$filePath', '$total', '$appno', '$date', '$time', '$status', '$examdate')";

$sqli = mysql_query ("UPDATE regcode SET status = 'used' WHERE code = '$code_id'");

if ($query){
 header("Location:student_form.php");

}

mysql_query($query) or die ('Error, query failed');

mysql_close();
}

}

?>

Line 78 is wrong -- it should be lowercase "s". To clarify, your initial form has

<input style="font-size:18px; height:45px; font-weight:bold; color:#0033FF" type="submit" style="height:50px" name="submit1" value="Save / Submit Form" >

Notice that the value of the name attribute is "submit1" (again, lowercase "s").

Good day, I have done that and is still not posting..I guess its the file upload scripts that is causing it...

Your code above begins with:

<?php
require 'database.php';
$code_id = $_SESSION['SESS_CODE_NAME'];

Are you calling session_start(); at the beginning of database.php? If not, then $code_id will not have the value you expect.

Also on line 178 I see:

$q = mysql_query ("SELECT * FROM studentreg WHERE jamb='$jamb'");

but I don't see $jamb being initialized anywhere. If undertand you correctly, you have a file with a form that submits the script above. If that is the case, you need to initialize $jamb on the script above.

I suggest you start adding debugging statements to help you track the bug in the script. For example, lines 77-82 above could be changed to:

$errors=Array();

echo '<pre>' . __FILE__ . '[' . __LINE__. '] $_SESSION=' . print_r($_SESSION,true) . '</pre>';

echo '<pre>' . __FILE__ . '[' . __LINE__. '] $_POST=' . print_r($_POST,true) . '</pre>';

echo '<pre>' . __FILE__ . '[' . __LINE__. '] $_FILES=' . print_r($_FILES,true) . '</pre>';

if( array_key_exists('submit1',$_POST) )
{
    echo 'Executing line ' . __LINE__ .'<br/>';
    if(!empty($_FILES))
    {
         echo 'Executing line ' . __LINE__ .'<br/>';

        // these are your "settings"           
        $errors=Array();

        if( array_key_exists('submit1',$_POST) )

That way when you submit the first form/page to the script above, you should be able to see which lines are being executed in addition to the critical data from the various arrays and see if they are missing. From there you should be able to track down the reason why they are missing.

I tried the solution above, but i still got the samething..The breakdown is The first file which is /register.php sends information to regconfirm.php with the users information that has been entered, for correction and under the regconfirm.php page, the photo and file upload will come up, then after that, it will connect to register.php where we have the script i posted above, then if sucessful, It will proceed to student_form.php which in turn picks the stored form from the db and displays it to the student for print out...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.