Upload page problems.....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
flouts
Forum Newbie
Posts: 6
Joined: Mon Dec 22, 2003 11:08 am

Upload page problems.....

Post by flouts »

Hi there to all!

I am pretty new to php....well really new...lol...and i am trying to build an upload php page...

Since i dont consider myself a programmer i took some free php scripts and tried to adjust em to my needs...i got a login script and an upload script...

I am using an MySql database to hold all the info for the users..

Well i have managed to put those scripts to work together...which means login works redirects to upload page...i can upload files..everything is ok..


Now what i want to do is to change the directory to which one uploads files depending on the username...
Here is briefly hoe the whole thing works and whats my idea of implementing it.
There is the index page where one inputs username and password.When the login button is pressed the data from the textfields are sent to the login.php page where authentication takes place(by checkin th Mysql db) and if it is successful it redirects to the upload page.
In the upload page there is a variable which holds the the name of the directory where the files are uploaded.

Now my thought is to add in the database, in the table that the user details are held a field folder where the name of the folder for each user is held.....and then in the upload page to run a query that derives the folder from the db according to the name...

The problem now is that i cant find a way to post the name from the index page to the upload page....
Can somebody help....i know it is a bit difficult without the code but it is pretty long......should i post it??

Cheers guys!
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post by aquila125 »

So you want to know wich user has logged in?

Take a look at sessions.. that's what you need...

put something like this in your login script:

(on top of page)
session_start();

(place where username and password have been checked)
$_SESSION['username']=$userame; //(or whatever you got it stored in)

then on the upload page, start again with session_start() and then you can use $_SESSION['username'] as a variable... use it in your query and you'r off!
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Re: Upload page problems.....

Post by delorian »

flouts wrote:The problem now is that i cant find a way to post the name from the index page to the upload page....
You can use sessions http://php.net/sessions or cookies, or you can try passing it in URL (bad way) with GET method or with hidden form field with POST method (also not good method)
flouts wrote:Can somebody help....i know it is a bit difficult without the code but it is pretty long......should i post it??
Yes, you should. :D
flouts
Forum Newbie
Posts: 6
Joined: Mon Dec 22, 2003 11:08 am

Post by flouts »

Cheers mate!!

As I can see in the script i am using there is a session_start...

I will try it right away and post results...

ps. so bloody easy...lol
flouts
Forum Newbie
Posts: 6
Joined: Mon Dec 22, 2003 11:08 am

Post by flouts »

well.....while i am trying the session start thingy...

Here is the code of the login page\

Code: Select all

<?php

// login.php - performs validation 

// authenticate using form variables
$status = authenticate($HTTP_POST_VARS&#1111;'f_user'],$HTTP_POST_VARS&#1111;'f_pass']);

// if  user/pass combination is correct
if ($status == 1)
&#123;
	// initiate a session
	session_start();
	
	// register some session variables
	session_register("SESSION");

	// including the username
	session_register("SESSION_UNAME");
	$SESSION_UNAME = $f_user;
	
	// redirect to protected page
	header("Location: upload.php");
	exit();
&#125;
else
// user/pass check failed
&#123;
	// redirect to error page
	header("Location: error.php?e=$status");
	exit();
&#125;
// authenticate username/password against a database
// returns: 0 if username and password is incorrect
//          1 if username and password are correct
function authenticate($user, $pass)
&#123;
	// configuration variables
	// normally these should be sourced from an external file
	// for example: include("dbconfig.php");
	// variables explicitly set here for illustrative purposes
	$db_host = "aias";
	$db_user = "*****";
	$db_pass = "*****";
	$db_name = "users";
	
	// check login and password
	// connect and execute query
	$connection = mysql_connect($db_host, $db_user, $db_pass) or die
("Unable to connect!");
	$query = "SELECT id from usr_det WHERE uid = '$user' AND
 pw = PASSWORD('$pass')";
	mysql_select_db($db_name);
	$result = mysql_query($query, $connection) or die ("Error in
query: $query. " . mysql_error());
	
	// if row exists -> user/pass combination is correct
	if (mysql_num_rows($result) == 1)
	&#123;
		return 1;
	&#125;
	// user/pass combination is wrong
	else
	&#123;
		return 0;
	&#125;
&#125;
?>
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

making the code clearear no changes

Code: Select all

// login.php - performs validation

// authenticate using form variables
$status = authenticate($HTTP_POST_VARS['f_user'],$HTTP_POST_VARS['f_pass']);

// if  user/pass combination is correct
if ($status == 1)
{
   // initiate a session
   session_start();
   
   // register some session variables
   session_register("SESSION");

   // including the username
   session_register("SESSION_UNAME");
   $SESSION_UNAME = $f_user;
   
   // redirect to protected page
   header("Location: upload.php");
   exit();
}
else
// user/pass check failed
{
   // redirect to error page
   header("Location: error.php?e=$status");
   exit();
}
// authenticate username/password against a database
// returns: 0 if username and password is incorrect
//          1 if username and password are correct
function authenticate($user, $pass)
{
   // configuration variables
   // normally these should be sourced from an external file
   // for example: include("dbconfig.php");
   // variables explicitly set here for illustrative purposes
   $db_host = "aias";
   $db_user = "*****";
   $db_pass = "*****";
   $db_name = "users";
   
   // check login and password
   // connect and execute query
   $connection = mysql_connect($db_host, $db_user, $db_pass) or die
("Unable to connect!");
   $query = "SELECT id from usr_det WHERE uid = '$user' AND
pw = PASSWORD('$pass')";
   mysql_select_db($db_name);
   $result = mysql_query($query, $connection) or die ("Error in
query: $query. " . mysql_error());
   
   // if row exists -> user/pass combination is correct
   if (mysql_num_rows($result) == 1)
   {
      return 1;
   }
   // user/pass combination is wrong
   else
   {
      return 0;
   }
}
flouts
Forum Newbie
Posts: 6
Joined: Mon Dec 22, 2003 11:08 am

Post by flouts »

well....i cant find a way in this...

tried using the $_SESSION[' '] thingy.......i get some errors saying unexpected T_string and such...

i tried using a variable that is declared in the login page named $SESSION_UNAME....and passed it as a parameter in the MySql query in the upload page....i get an error in sql syntax....

Anyway here is the upload page code as it is now....login page is the same as above...no changes...

Any help would be great

aLSO THERE IS AN AUTHENTICATION SCRIPT IN THIS PAGE ALSO...WHICH I HAVE DISABLED..SO DONT LOOK AT IT..

Code: Select all

<?php require_once('../Connections/rs1.php'); ?>
<?php
mysql_select_db($database_rs1, $rs1);
$query_Recordset2 = "SELECT folder FROM usr_det WHERE uid = '%s' , $SESSION_UNAME";
$Recordset2 = mysql_query($query_Recordset2, $rs1) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<?


// session check
session_start();
if (!session_is_registered("SESSION"))
{
	// if session check fails, invoke error handler
	header("Location: error.php?e=2");
	exit();
}
?> <?php

#---------------------------------------------#
# file upload manager 1.3
# 13.10.2003
# 
# written by thepeak (adam johnson)
# copyright (c) 2003 thepeak of mtnpeak.net
#
# www: http://webdev.mtnpeak.net
# www: http://www.xd3v.com
# email: thepeak@gmx.net
#
# A simple, powerful tool to upload and manage 
# files using your web browser.
# 
# This program is free software; you can redistribute 
# it and/or modify it under the terms of the GNU General 
# Public License as published by the Free Software 
# Foundation; either version 2 of the License, or 
# (at your option) any later version, as long as the 
# copyright info and links stay intact. You may not sell
# this program under any circumstance without written 
# permission from the author. Full license is in the 
# included ZIP/GZ package this script was downloaded in.
#
# *please send me feedback - and enjoy!
#---------------------------------------------#

################## configurations ####################

# header & title of this file
$title = "File Upload Manager";

# individual file size limit - in bytes (102400 bytes = 100KB)
$file_size_ind = "9000000";
$hiddenpath = $hidden_path;
# the upload store directory (chmod 777)
$dir_store= $row_Recordset2['folder'];

# the images directory
$dir_img= "img";

# the style-sheet file to use (located in the "img" directory, excluding .css)
$style = "style-def";

# the file type extensions allowed to be uploaded
$file_ext_allow = array("gif","jpg","jpeg","png","txt","doc","rtf","tif","pdf");

# option to display the file list
# to enable/disable, enter '1' to ENABLE or '0' to DISABLE (without quotes)
$file_list_allow = 1;

# option to allow file deletion
# to enable/disable, enter '1' to ENABLE or '0' to DISABLE (without quotes)
$file_del_allow = 0;

# option to password-protect this script [-part1]
# to enable/disable, enter '1' to ENABLE or '0' to DISABLE (without quotes)
$auth_ReqPass = 0;

# option to password-protect this script [-part2]
# if "$auth_ReqPass" is enabled you must set the username and password
$auth_usern = "username";
$auth_passw = "password";

################ end of configurations ###############


# DO NOT ALTER OR EDIT BELOW THIS LINE UNLESS YOU ARE AN ADVANCED PHP PROGRAMMER

?>
<?
if (@phpversion() < '4.1.0') {
    $_FILE = $HTTP_POST_FILES;
    $_GET = $HTTP_GET_VARS;
    $_POST = $HTTP_POST_VARS;
}
clearstatcache();
error_reporting(E_ALL & ~E_NOTICE);
$fum_vers = "1.3"; # do not edit this line, the script will not work!!!
$fum_info_full = "File Upload Manager v$fum_vers";

function authDo($auth_userToCheck, $auth_passToCheck) 
{
	global $auth_usern, $auth_passw;
	$auth_encodedPass = md5($auth_passw);
	
	if ($auth_userToCheck == $auth_usern && $auth_passToCheck == $auth_encodedPass) {
	$auth_check = TRUE;
	} else {
	$auth_check = FALSE;
	} 
	return $auth_check;
	}
	
	if (isset($logout)) {
	setcookie ('fum_user', "",time()-3600); 
	setcookie ('fum_pass', "",time()-3600);
	}
		
	if (isset($login)) {
	$auth_password_en = md5($auth_formPass); 
	$auth_username_en = $auth_formUser;

	if (authDo($auth_username_en, $auth_password_en)) { 
	setcookie ('fum_user', $auth_username_en,time()+3600); 
	setcookie ('fum_pass', $auth_password_en,time()+3600); 
	$auth_msg = "<b>Authentication successful!</b> The cookies have been set.<br><br>".
	$auth_msg . "Your password (MD5 encrypted) is: $auth_password_en";
	} else { 
	$auth_msg = "<b>Authentication error!</b>";
	}
}

if (($_GET[act]=="dl")&&$_GET[file]) 
{
	if ($auth_ReqPass != 1 || ($auth_ReqPass == 1 && isset($fum_user) && !isset($logout))) { 
	if ($auth_ReqPass != 1 || ($auth_ReqPass == 1 && authDo($fum_user, $fum_pass))) {

	$value_de=base64_decode($_GET[file]);
	$dl_full=$dir_store."/".$value_de;
	$dl_name=$value_de;

	if (!file_exists($dl_full))
	{ 
	echo"ERROR: Cannot download file, it does not exist.<br>»<a href="$_SERVER[PHP_SELF]">back</a>";  
	exit();
	} 
	
	header("Content-Type: application/octet-stream");
	header("Content-Disposition: attachment; filename=$dl_name");
	header("Content-Length: ".filesize($dl_full));
	header("Accept-Ranges: bytes");
	header("Pragma: no-cache");
	header("Expires: 0");
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
	header("Content-transfer-encoding: binary");
			
	@readfile($dl_full);
	
	exit();

	}
	}
}

function getlast($toget)
{
	$pos=strrpos($toget,".");
	$lastext=substr($toget,$pos+1);

	return $lastext;
}

function replace($o)
{
	$o=str_replace("/","",$o);
	$o=str_replace("","",$o);
	$o=str_replace(":","",$o);
	$o=str_replace("*","",$o);
	$o=str_replace("?","",$o);
	$o=str_replace("<","",$o);
	$o=str_replace(">","",$o);
	$o=str_replace(""","",$o);
	$o=str_replace("|","",$o);
	
	return $o;
}

?>
<!-- <?=$fum_info_full?> -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><? echo ($title) ? ($title) : ("File Upload Manager"); ?></title>
<link rel="stylesheet" href="<?=$dir_img?>/<?=$style?>.css" type="text/css">
<?
	if ($auth_ReqPass == 1) 
	{ 
		if (isset($login) || isset($logout)) {
			echo("<meta http-equiv='refresh' content='2;url=$_SERVER[PHP_SELF]'>");
		}
	}
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#F7F7F7">
<div align="center"><img src="../images/logo.gif" width="700" height="96"><br>
  <br>
</div>
<center>
<?	
	if ($auth_ReqPass != 1 || ($auth_ReqPass == 1 && isset($fum_user) && !isset($logout))) { 
	if ($auth_ReqPass != 1 || ($auth_ReqPass == 1 && authDo($fum_user, $fum_pass))) {
?>

  <p>&nbsp;</p>
  <table width="560" cellspacing="0" cellpadding="0" border="0">
  <tr>
      <td><font size="3"><b></b></font>&nbsp;&nbsp; </td>
   </tr>
</table>
<?
	if (!eregi("777",decoct(fileperms($dir_store))))
	{
		echo"<br><br><b><h4><font color="FF0000">ERROR: cannot access the upload store file directory. please chmod the "$dir_store" directory with value 0777 (xrw-xrw-xrw)!</h4></font></b><br>»<a href="$_SERVER[PHP_SELF]">refresh</a>";
	}
	else
	{
		if (!$_FILES[fileupload])
		{
?>
<table width="560" cellspacing="0" cellpadding="0" border="0" class="table_decoration" style="padding-top:5px;padding-left=5px;padding-bottom:5px;padding-right:5px">
  <form method="post" enctype="multipart/form-data">
  <tr>
        <td><img src="img/selectfile.jpg" width="198" height="15" align="right"></td>
        <td><input type="file" name="fileupload" class="textfield" size="30"></td>
  </tr>
  <tr>
        <td><img src="img/rename.jpg" width="198" height="16" align="right"></td>
        <td><input type="text" name="rename" class="textfield" size="46"></td>
  </tr>
  <tr>
        <td><img src="img/filesall.jpg" width="198" height="15" align="right"></td>
        <td>
	<?
	for($i=0;$i<count($file_ext_allow);$i++)
	{
		if (($i<>count($file_ext_allow)-1))$commas=", ";else $commas="";
		list($key,$value)=each($file_ext_allow);
		echo $value.$commas;
	}
	?>
    </td>
  </tr>
  <tr>
        <td><img src="img/maxsiz.jpg" width="198" height="17" align="right"></td>
	<td>
		<b><?
			if ($file_size_ind >= 1048576) 
			{
				$file_size_ind_rnd = round(($file_size_ind/1024000),3) . " MB";
			} 
			elseif ($file_size_ind >= 1024) 
			{	
				$file_size_ind_rnd = round(($file_size_ind/1024),2) . " KB";
			} 
			elseif ($file_size_ind >= 0) 
			{
				$file_size_ind_rnd = $file_size_ind . " bytes";
			} 
			else 
			{
				$file_size_ind_rnd = "0 bytes";
			}
			
			echo "$file_size_ind_rnd";
		?></b>
	</td>
  </tr>
  <tr>
    <td colspan="2"><input type="submit" value="upload" class="button">&nbsp;<input type="reset" value="clear" class="button"></td>
  </tr>
  </form>
</table>
<?
		if ((!$_GET[act]||!$_GET[file])&&$_GET[act]!="delall")
		{
			$opendir = @opendir($dir_store);

			while ($readdir = @readdir($opendir))
			{
				if ($readdir<>"." && $readdir<>".." && $readdir != "index.html")
				{
					$filearr[] = $readdir;
				}
				$sort=array();
				for($i=1;$i<=count($filearr);$i++)
				{
					$key = sizeof($filearr)-$i;
					$file = $filearr[$key];

					$sort[$i]=$file;
				}
				asort($sort);
			}
?>
  <p>&nbsp;</p>
  <p><font face="Arial, Helvetica, sans-serif"><a href="logout.php">Logout</a></font><br>
  </p>
  <table width="560" cellspacing="0" cellpadding="0" border="0" class="table_decoration" style="padding-left:5px">
  <tr>
    <td><b>admin tools:</b>
<? 
	if ($file_del_allow != 1 && $auth_ReqPass != 1)
	{
		echo"<i>none</i>";
	}

	if ($file_del_allow == 1 && $file_list_allow == 1 && (count($filearr) >= 1)) 
	{ 
		echo"<a href="javascript:;" onClick="cf=confirm('Are you sure you want to delete ALL FILES?');if (cf)window.location='?act=delall'; return false;" style="font-size: 9px;"><delete all files></a>";
	}
	
	if ($auth_ReqPass == 1) 
	{ 
		echo"&nbsp;<a href="$_SERVER[PHP_SELF]?logout=1" style="font-size: 9px;"><log-out><a>";
	}
?>
    </td>
  </tr>
</table>
<br>
<?	
			if ($file_list_allow == 1 && (count($filearr) >= 1)) 
			{
?>
<table width="560" cellspacing="0" cellpadding="0" border="0" class="table_decoration" style="padding-left:6px">
  <tr bgcolor="#DBDBDB">
    <td align="left" width="46%">FILE NAME</td>
    <td align="center" width="12%">FILE TYPE</td>
    <td align="center" width="12%">FILE SIZE</td>
    <td align="center" width="30%">FUNCTIONS</td>
  </tr>
<?
				for($i=1;$i<=count($sort);$i++)
				{
					list($key,$value)=each($sort);

					if ($value)
					{
						$value_en = base64_encode($value);
						$value_view=$value;
						
							if (strlen($value) >= 48) 
							{ 
								$value_view = substr($value_view, 0, 45) . '...';
							}
?>
<tr>
    <td width="30%"><?="<a href="?act=view&file=$value_en">$value_view</a>"?></td>
    <td align="center" width="5%"><? echo strtoupper(getlast($value)); ?></td>
    <td align="center" width="5%"><?

    	$value_full = $dir_store."/".$value;
    	$file_size = filesize($value_full);
		
		if ($file_size >= 1048576) 
		{
			$show_filesize = number_format(($file_size / 1048576),2) . " MB";
		} 
		elseif ($file_size >= 1024) 
		{
			$show_filesize = number_format(($file_size / 1024),2) . " KB";
		} 
		elseif ($file_size >= 0) 
		{
			$show_filesize = $file_size . " bytes";
		} 
		else 
		{
			$show_filesize = "0 bytes";
		}

		echo "$show_filesize";
		
?></td>
    <td align="center" width="5%"><?="<a title="View File" href="?act=view&file=$value_en"><view></a>"?> | 
<?
	if ($file_del_allow == 1) 
	{ 
		echo"<a title="Download file" href="?act=dl&file=$value_en"><dl></a>";
 	} 
	else 
	{ 
		echo"<a title="Download file" href="?act=dl&file=$value_en"><download></a>"; 
	} 

	if ($file_del_allow == 1) 
	{ 
		echo"&nbsp;|&nbsp;<a title="Delete file" href="javascript:;" onClick="cf=confirm('Are you sure you want to delete this file?');if (cf)window.location='?act=del&file=$value_en'; return false;"><delete></a>";
	} 
	else 
	{ 
		echo"&nbsp;"; 
	} 
?>
    </td>
</tr>
<?
				}
				else
				{
					echo"<br>";
				}
				}
?>
</table></center>
<?
			}
		}
		elseif (($_GET[act]=="view")&&$_GET[file])
		{
			$value_de = base64_decode($_GET[file]);
			echo"<script language="javascript">\nViewPopup = window.open("$dir_store/$value_de", "fum_viewfile", "toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,location=no,width=640,height=480")\nViewPopup.document.bgColor="#F7F7F7"\nViewPopup.document.close()\n</script>";
			echo"<br><img src="$dir_img/info.gif" width="15" height="15">&nbsp;<b><font size="2">file opened!</font></b><br>»<a href="$_SERVER[PHP_SELF]">back</a><br><br><br>If the file did not display, you must <b>disable</b> your popup manager, or enable javascript in your browser.";
		}
		elseif (($_GET[act]=="del")&&$_GET[file])
		{
			$value_de = base64_decode($_GET[file]);
			@unlink($dir_store."/$value_de");
			echo"<br><img src="$dir_img/info.gif" width="15" height="15">&nbsp;<b><font size="2">file has been deleted!</font></b><br>»<a href="$_SERVER[PHP_SELF]">back</a>";
		}
		if ($_GET[act]=="delall")
		{
			$handle = opendir($dir_store);
			while($file=readdir($handle))
			if (($file != ".")&&($file != ".."))
			@unlink($dir_store."/".$file);
			closedir($handle);

			echo"<br><img src="$dir_img/info.gif" width="15" height="15">&nbsp;<b><font size="2">all files have been deleted!</font></b><br>»<a href="$_SERVER[PHP_SELF]">back</a>";
		}

	}
	else
	{
		echo"<br><br>";
		$uploadpath=$dir_store."/";
		$source=$_FILES[fileupload][tmp_name];
		$fileupload_name=$_FILES[fileupload][name];
		$weight=$_FILES[fileupload][size];

		for($i=0;$i<count($file_ext_allow);$i++)
		{
			if (getlast($fileupload_name)!=$file_ext_allow[$i])
				$test.="~~";
		}
		$exp=explode("~~",$test);

		if (count($exp)==(count($file_ext_allow)+1))
		{
			echo"<br><img src="$dir_img/error.gif" width="15" height="15">&nbsp;<b><font size="2">ERROR: your file type is not allowed (".getlast($fileupload_name).")</font>, or you didn't specify a file to upload.</b><br>»<a href="$_SERVER[PHP_SELF]">back</a>";
		}
		else
		{

			if ($weight>$file_size_ind)
			{
				echo"<br><img src="$dir_img/error.gif" width="15" height="15">&nbsp;<b><font size="2">ERROR: please get the file size less than ".$file_size_ind." BYTES  (".round(($file_size_ind/1024),2)." KB)</font></b><br>»<a href="$_SERVER[PHP_SELF]">back</a>";
			}
			else
			{

				foreach($_FILES[fileupload] as $key=>$value)
				{
					echo"<font color="#3399FF">$key</font> : $value <br>";
				}

				echo "<br>";

				$dest = ''; 

				if (($source != 'none') && ($source != '' ))
				{
					$dest=$uploadpath.$fileupload_name;
					if ($dest != '')
					{
						if (file_exists($uploadpath.$fileupload_name))
						{
							echo"<br><img src="$dir_img/error.gif" width="15" height="15">&nbsp;<b><font size="2">ERROR: that file has already been uploaded before, please choose another file</font></b><br>»<a href="$_SERVER[PHP_SELF]">back</a>";
						}
						else
						{
							if (copy($source,$dest))
							{
								if ($_POST[rename])
								{
									$_POST[rename]=replace($_POST[rename]);
									$exfile=explode(".",$fileupload_name);
									
									if (@rename("$dir_store/$fileupload_name","$dir_store/$_POST[rename].".getlast($fileupload_name))) 
									{
										echo"<br><img src="$dir_img/info.gif" width="15" height="15">&nbsp;<b><font size="2">file has been renamed to $_POST[rename].".getlast($fileupload_name)."!</font></b></font><br>";
									}
								}
								echo"<br><img src="$dir_img/info.gif" width="15" height="15">&nbsp;<b><font size="2">file has been uploaded!</font></b><br>»<a href="$_SERVER[PHP_SELF]">back</a>";
							}
							else
							{
								echo"<br><img src="$dir_img/error.gif" width="15" height="15">&nbsp;<b><font size="2">ERROR: cannot upload, please chmod the dir to 777</font></b><br>»<a href="$_SERVER[PHP_SELF]">back</a>";
							}
						}
					}
				}
			}
		}
	}
}

#/# end of main script, start authentication code IF user not logged in IF $auth_ReqPass is enabled

	} 
	else 
	{
		echo("<p><img src="$dir_img/error.gif" width="15" height="15">&nbsp;Authentication error</p>" .
"<p><a href='$_SERVER[PHP_SELF]?logout=1'>Delete cookies and login again<a></p>");
	}
	} 
	else 
	{

	if (!isset($login) || isset($relogin)) {
?>
<font size="3"><b><i><? echo ($title) ? ($title) : ("File Upload Manager"); ?></i> - Authentication</b></font><br><br>
<table class="table_auth"><tr><td><center>
Please enter the username and password to enter the restricted area.<br>
You must have cookies enabled in your browser to continue.
</center></td></tr></table>
<form action="<?=$_SERVER[PHP_SELF]?>?login=1" method="POST"><p>
Username: <input type="text" name="auth_formUser" size="20"><br>
Password: <input type="password" name="auth_formPass" size="20">
<p><input type="submit" name="submit" class="button" value="Log-In"></p>
</form></center>
<?
	} 
	elseif (isset($login)) 
	{
		echo("<p>$auth_msg</p>" . "<p>You'll be redirected in 2 seconds!</p>");
	}
	}
?>
</body>
</html>
<?php
mysql_free_result($Recordset2);
?>

<!-- Copyright (c) 2003 thepeak. Get your own copy of this free PHP script from http://www.mtnpeak.net -->
<?php


?>
Last edited by flouts on Mon Dec 22, 2003 12:26 pm, edited 1 time in total.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

instead of uing

Code: Select all

use

Code: Select all

for php ... so you have the colors and it's way easier to read 
(you can edit your msg and change manually the

Code: Select all

for

Code: Select all

)
flouts
Forum Newbie
Posts: 6
Joined: Mon Dec 22, 2003 11:08 am

Post by flouts »

Any ideas guys??????
Sorry if i am a bit hasty.... :(
flouts
Forum Newbie
Posts: 6
Joined: Mon Dec 22, 2003 11:08 am

Post by flouts »

Solved Guys!!!

Thanx to all for their contributions and escpecially to aquila125!!

You were spot on mate.....i was a bit dumb in implementing it....

Cheers!!!!
Post Reply