Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $ftp_server = "localhost";
- $ftp_user_name = "กูไม่บอกรหัส";
- $ftp_user_pass = "กูไม่บอก";
- $port = "2002" ;
- $destination_file = $_FILES['file']['name'];
- $source_file = $_FILES['file']['tmp_name'];
- $size_file = $_FILES['file']['size'];
- if ($destination_file == "") {
- header("Location:add_student.php");
- exit;
- }
- if (strtoupper(substr($destination_file, -4)) != '.CSV' ) {
- header("Location:add_student.php");
- exit;
- }
- // set up basic connection
- $conn_id = ftp_connect($ftp_server, $port);
- // login with username and password
- $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
- ftp_chdir($conn_id, "CSV Files");
- // check connection
- if ((!$conn_id) || (!$login_result)) {
- echo "FTP connection has failed!";
- echo "Attempted to connect to $ftp_server for user $ftp_user_name";
- exit;
- } else {
- // echo "Connected to $ftp_server, for user $ftp_user_name<br/>";
- }
- // upload the file
- $upload = ftp_put($conn_id, 'student.csv', $source_file, FTP_BINARY);
- // check upload status
- if (!$upload) {
- echo "FTP upload has failed!";
- }
- // close the FTP stream
- ftp_close($conn_id);
- ?>
- <!DOCTYPE html>
- <!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
- <!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
- <!--[if IE 10]> <html lang="en" class="ie10"> <![endif]-->
- <!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
- <!-- BEGIN HEAD -->
- <?php
- /*
- session_start();
- if ($_SESSION['sess_userid'] == "") {
- header("Location: ../../staffLogin.php");
- die();
- }
- if ($_SESSION['sess_position'] != "general") {
- header("Location: ../../staffLogin.php");
- die();
- }
- */
- include '../../../connection.php';
- // $strSQL = "SELECT * FROM staff_login WHERE username = '" . $_SESSION['sess_userid'] . "' ";
- mysql_query("SET NAMES UTF8");
- // $objQuery = mysql_query($strSQL);
- // $objResult = mysql_fetch_array($objQuery);
- $today = getdate();
- $nowyear = $today['year'] + 543;
- ?>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Dormitory Management System</title>
- <!-- Tell the browser to be responsive to screen width -->
- <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
- <!-- Bootstrap 3.3.6 -->
- <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css">
- <!-- Font Awesome -->
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
- <!-- Ionicons -->
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
- <!-- Theme style -->
- <link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">
- <!-- AdminLTE Skins. Choose a skin from the css/skins
- folder instead of downloading all of them to reduce the load. -->
- <link rel="stylesheet" href="../../dist/css/skins/_all-skins.min.css">
- <!-- bootstrap wysihtml5 - text editor -->
- <link rel="stylesheet" href="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
- <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
- <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
- <!--[if lt IE 9]>
- <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
- <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
- <![endif]-->
- </head>
- <!-- END HEAD -->
- <!-- BEGIN BODY -->
- <body class="fixed-top">
- <?php //include 'stafftag.php' ?>
- <div class="container-fluid">
- <!-- BEGIN PAGE HEADER-->
- <div class="row-fluid">
- <div class="span12">
- <!-- BEGIN PAGE TITLE & BREADCRUMB-->
- <h3 class="page-title">
- เพิ่มรายชื่อนักศึกษา
- </h3>
- <ul class="breadcrumb">
- <li>
- <i class="icon-home"></i>
- <a href="index.php">หน้าแรก</a> <span class="divider">/</span>
- </li>
- <li class="active">เพิ่มรายชื่อนักศึกษา</li>
- </ul>
- <!-- END PAGE TITLE & BREADCRUMB-->
- </div>
- </div>
- <!-- END PAGE HEADER-->
- <div class="widget-body form">
- <!-- BEGIN FORM-->
- <form class="form-horizontal has-validation-callback" method="post" action="StudentAddtoMySQL.php">
- <!--student data-->
- <div class="panel panel-default">
- <div class="panel-body">
- <legend>รายชื่อนักศึกษา</legend>
- <!--line1-->
- <div class="form-group">
- <div class="widget-body form">
- <!-- BEGIN FORM-->
- <div class="box-body">
- <h4> ปีการศึกษา <?php echo $_POST['txtyear']; ?> </h4>
- <table class="table table-bordered" id="sample_1">
- <thead>
- <tr class="btn-info">
- <th>ลำดับ</th>
- <th>โครงการที่รับสมัคร</th>
- <th>สาขาวิชาที่สมัคร</th>
- <th>หมายเลขบัตรประชาชน</th>
- <th>ชื่อ</th>
- <th>นามสกุล</th>
- <th>เพศ</th>
- <th>หมายเลขโทรศัพท์</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $row = 0;
- $fp = @ fopen("../../files/CSV Files/student.csv", "r");
- if (!$fp) {
- echo "ไม่สามารถเปิดไฟล์ได้ โปรดลองอีกครั้งในภายหลัง";
- exit;
- }
- while (($data = fgetcsv($fp, 3000, ",")) !== FALSE) {
- $num = count($data);
- if ($row == 0) {
- $row++;
- } else { ?>
- <tr>
- <td>
- <?php
- echo $row;
- $row++;
- ?>
- </td>
- <td><?php echo $data[0]; ?></td>
- <td><?php echo $data[1]; ?></td>
- <td><?php echo $data[2]; ?></td>
- <td><?php echo $data[3]; ?></td>
- <td><?php echo $data[4]; ?></td>
- <td><?php echo $data[5]; ?></td>
- <td><?php echo $data[6]; ?></td>
- </tr>
- <?php
- }
- }
- fclose($fp);
- ?>
- </tbody>
- </table>
- </div>
- <!-- END FORM-->
- </div>
- </div>
- <hr>
- <div id="success"></div>
- <!-- For success/fail messages -->
- <div align="right">
- <button class="btn btn-danger" data-dismiss="fileupload" onclick="history.back();">ยกเลิก</button>
- <button type="submit" class="btn btn-info" name="file" value="studentlist.csv">เพิ่มรายชื่อลงฐานข้อมูล</button>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- <?php
- // include 'stafftag2.php'
- ?>
- <!-- jQuery 2.2.0 -->
- <script src="../../plugins/jQuery/jQuery-2.2.0.min.js"></script>
- <!-- Bootstrap 3.3.6 -->
- <script src="../../bootstrap/js/bootstrap.min.js"></script>
- <!-- FastClick -->
- <script src="../../plugins/fastclick/fastclick.js"></script>
- <!-- AdminLTE App -->
- <script src="../../dist/js/app.min.js"></script>
- <!-- AdminLTE for demo purposes -->
- <script src="../../dist/js/demo.js"></script>
- <!-- CK Editor -->
- <script src="https://cdn.ckeditor.com/4.5.7/standard/ckeditor.js"></script>
- <!-- Bootstrap WYSIHTML5 -->
- <script src="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
- <script>
- $(function () {
- // Replace the <textarea id="editor1"> with a CKEditor
- // instance, using default configuration.
- CKEDITOR.replace('editor1');
- //bootstrap WYSIHTML5 - text editor
- $(".textarea").wysihtml5();
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement