I have been using PHP for several years now, and have never run across this problem. On the very last function (pageSortData()) cannot seem to access any of the protected variables in the class (IPTables). I can echo any of the variables with any of the other functions, just not the last one. Any ideas? This is really bugging me.. Thanks in advance!
#include.inc
<?PHP
class IPTables {
private $SELF="/TEST/index.php";
private $sqlConnection;
private $sqlResults;
private $fieldCount;
private $userName;
private $userPasswd;
private $sqlDatabase;
private $fileName;
private $fileSize;
private $fileData;
private $fileHandle;
public function sqlStart(){
$this->sqlConnection = mysql_connect("<host>","<user>","<pass>");
}
private function sqlDatabase($database){
mysql_select_db($database,$this->sqlConnection);
}
private function sqlQuery($query_string){
$this->sqlResults = mysql_query($query_string);
}
private function sqlStop(){
mysql_close($this->sqlConnection);
}
public function fileGetData(){
$this->fileName = $_FILES['file_upload']['tmp_name'];
$this->fileSize = $_FILES['file_upload']['size'];
$this->fileHandle = fopen($this->fileName,"r");
if(!$this->fileHandle){
?>
<html>
<head>
<title>File Upload Error!</title>
<?include("style.css")?>
</head>
<body>
<div align="center">
Could Not Upload File!
<BR>
<button onClick="history.go(-1)" class="input_button">Go Back</button>
</body>
</html>
<?PHP
}else{
$this->fileData = fread($this->fileHandle,$this->fileSize);
return 1;
}
}
public function pageStartMenu(){
?>
<html>
<head>
<title>Main Page</title>
<?include("style.css")?>
</head>
<body>
<form method="post" action="<?=$this->SELF?>">
<input class="input_button" type="submit" name="batch" value="Batch">
<br>
<input class="input_button" type="submit" name="manual" value="Manual">
</form>
</body>
</html>
<?PHP
}
public function pageBatchEntry(){
?>
<html>
<head>
<title>Batch Entry Form</title>
<?include("style.css")?>
</head>
<body>
<font face="Lucida Console">
<form method="post" action="<?=$this->SELF?>">
<table border=0 cellpadding=0 cellspacing=0>
<tr><td>Number Of Fields </td><td><input class="input_text" type="text" name="field_count"></td></tr>
<tr><td>Type Of Input</td><td>(Paste<input type="radio" name="input_type" value="paste">) (File<input type="radio" name="input_type" value="file">)</td></tr>
<tr><td>User</td><td><input class="input_text" type="text" name="user_name"></td></tr>
<tr><td>Password</td><td><input class="input_text" type="password" name="password"></td></tr>
<tr><td>Database</td><td><select name="database">
<?PHP
$this->sqlStart();
$this->sqlDatabase("MAIN");
$this->sqlQuery("SHOW TABLES");
while($row = mysql_fetch_array($this->sqlResults)){
?>
<option value="<?=$row['Tables_in_MAIN']?>"><?=$row['Tables_in_MAIN']?></option>
<?PHP
}
?>
</td></tr>
<tr><td> </td><td><input class="input_button" type="submit" name="batch_submit" value="Continue"></td></tr>
</font>
</form>
</body>
</html>
<?PHP
}
function pageFileGet(){
$this->fieldCount = $_POST['field_count'];
$this->userName = $_POST['user_name'];
$this->userPasswd = $_POST['password'];
echo $this->fieldCount;
?>
<html>
<head>
<title>File Upload</title>
<?include("style.css")?>
</head>
<body>
<font face="Lucida Console">
<form method="post" action="<?=$this->SELF?>" enctype="multipart/form-data">
<table border=0 cellpadding=0 cellspacing=0>
<tr><td>File To Upload </td><td><input class="input_file" type="file" name="file_upload"></td></tr>
<tr><td></td><td><input class="input_button" type="submit" name="upload_submit" value="Upload"></td></tr>
</table>
</form>
</font>
</body>
</html>
<?PHP
}
function pageSortData(){
?>
<html>
<head>
<title>Select Your Fields</title>
<?include("style.css")?>
</head>
<body>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<?PHP
echo $this->fieldCount; //This and everything below does not work!!
for($a=0;$a<=$this->fieldCount-1;$a++){
?>
<td><select name="Field_<?=$a?>">
<?PHP
$this->sqlQuery("SHOW COLUMNS FROM phone_numbers");
while($row = mysql_fetch_array($this->sqlResults)){
?>
<option id="<?=$row['Field']?>"><?=$row['Field']?></option>
<?PHP
}
?>
</select></td>
<?PHP
}
?>
</table>
</body>
</html>
<?PHP
}
};
#index.php
<?PHP
include("include.inc");
$page = new IPTables();
if(!$_POST){
$page->pageStartMenu();
}
if(isset($_POST['batch'])){
$page->pageBatchEntry();
}
if(isset($_POST['batch_submit'])){
if($_POST['input_type'] == "file"){
$page->pageFileGet();
}
if($_POST['input_type'] == "paste"){
echo "Paste";
}
}
if(isset($_POST['upload_submit'])){
if($page->fileGetData() == 1){
$page->pageSortData();
}
}
?>