Uploading a text file and taking content out of it using php


#1

This is what I am trying to do I am trying to take text out of a text file using PHP I am uploading that file then I need to take the text out of it and input it into a SQL database. This is what I have so far.

[php]

<?php session_start(); $uid= $_SESSION['username']; $a=$_SESSION['accesslevel'] ; require_once ('mysql_connect.php'); // Connect to the db. if (isset($_POST['submit'])) { // Handle the form. $lines = file($_FILES['uploadedfile']['tmp_name']); foreach ($lines as $line){ $file = $line; $array = explode (",",$file); $query = "insert into group_list (phone_number, first_name, last_name) values ('$var0', '$var1', '$var2')"; } $message = NULL; // Create an empty new variable. $ins=escape_data($_POST['Instructor']); // Check for a class name. if (empty($_POST['group_name'])) { $gn = FALSE; $message .= '

You forgot to enter a Group Name!

'; } else { $gn = escape_data($_POST['group_name']); } if ($gn) { // If everything's OK. // add to database... $query = "insert into group_name (group_name) values ('$gn')"; $result = @mysql_query ($query); // Run the query. if (mysql_affected_rows() >0) { // Records added so update the aval field echo '', 'The Group was Added', ''; //now lets upload the file }}} ?> Group Name:




<? ob_end_flush(); ?>

[/php]
PLEASE HELP!!!

Admin Edit: Added PHP Code tags for readability. Please see http://phphelp.com/guidelines.php


#2

Please help with what? Does any of it work at this point? If so, which parts.