SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 37 of 37
  1. #26
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now it displays login incorrect even on a fresh load

    when using a user and pass in the database i get this error:

    DEBUG: SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='test' AND rest_pass = 'test'
    array(8) { [0]=> string(6) "100565" ["table_id"]=> string(6) "100565" [1]=> string(4) "test" ["rest_username"]=> string(4) "test" [2]=> string(4) "test" ["rest_pass"]=> string(4) "test" [3]=> string(13) "Paul & Sharon" ["contact_fname"]=> string(13) "Paul & Sharon" }
    Warning: Cannot modify header information - headers already sent by (output started at /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/mgmt_index.php:10) in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/mgmt_index.php on line 29

    when i use a user an pass not in the database i get this error:

    DEBUG: SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='sdfsf' AND rest_pass = 'sdfwer'
    bool(false) Array ( [track_id] => 100565 [track_name] => Paul & Sharon ) Array ( [username] => sdfsf [password] => sdfwer [submit] => Login )


    here is the code as it is now:

    Code:
    <?php
    error_reporting(E_ALL);
    session_start();
    include('db_con.php'); 
    
    
    
    $login_fail="true";
    if(isset($_POST['submit'])) {
    
    $sql = "SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'";
    
    echo 'DEBUG: '.$sql.'<br />';
    
    $User_Exists = mysql_query($sql) or die(mysql_error());
    
    $exists = mysql_num_rows($User_Exists);
    
    $row = mysql_fetch_array($User_Exists);
    
    var_dump($row);
    
     
    $username = $_POST['username']; 
    
    $password = $_POST['password']; 
    
    
    
    $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'", $db_link); 
    
            $exists = mysql_num_rows($User_Exists); 
    
            $row = mysql_fetch_array($User_Exists); 
    
             
    
            if($exists > 0) { 
    
            $_SESSION['track_id'] = $row['table_id']; 
    
            $_SESSION['track_name'] = $row['contact_fname']; 
    
             
    
    $login_fail = false;         
    
    header("Location: home.php"); 
    
    exit; 
    
             
    
            }else{ 
    
                $login_fail="true"; 
    
                print_r($_SESSION); 
    
                print_r($_POST); 
    
            } 
    
    } 
    
    ?>
    <html>
    
    	<head>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    		<meta name="generator" content="Adobe GoLive 5">
    		<title>Admin Page :: Login</title>
    	</head>
    
    	<body bgcolor="#ffffff">
    		<div align="center">
    			<font face="Verdana, Arial, Helvetica, sans-serif">Please log in: <br>
    				<br>
    				<? if ($login_fail=="true"){
    				echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>";
    				}
    				?><br>
    				<form name="FormName" action="<?=$PHP_SELF;?>" method="post">
    					<table border="0" cellpadding="0" cellspacing="2" width="180">
    						<tr height="19">
    							<td colspan="2" height="19">
    								<div align="center">
    									<font size="3"><b>
    										
    										Login</b></font></div>
    							</td>
    						</tr>
    						<tr>
    							<td>Username:</td>
    							<td><input type="text" name="username" CLASS="formTextbox" size="24"></td>
    						</tr>
    						<tr>
    							<td>Password:</td>
    							<td><input type="password" name="password" CLASS="formTextbox" size="24"></td>
    						</tr>
    						<tr>
    							<td colspan="2">
    								<div align="center">
    									<input type="submit" CLASS="formTextbox" name="submit" value="Login"></div>
    							</td>
    						</tr>
    					</table>
    				</form>
    			</font></div>
    	</body>
    
    </html>

  2. #27
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to remove or comment out the debugging lines. i.e
    PHP Code:
    //echo 'DEBUG: '.$sql.'<br />';
    //var_dump($row); 
    ..and anywhere else those debug lines appear in your script. They are not errors you're seeing, you're just seeing the debug code that we used to get rid of the errors

  3. #28
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    almost there, currently looks like this:
    Code:
    <?php
    //error_reporting(E_ALL);
    session_start();
    include('db_con.php'); 
    
    $login_fail="false";
    if(isset($_POST['submit'])) {
    $username = $_POST['username']; 
    
    $password = $_POST['password']; 
    //$sql = "SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'";
    
    //echo 'DEBUG: '.$sql.'<br />';
    
    //$User_Exists = mysql_query($sql) or die(mysql_error());
    
    //$exists = mysql_num_rows($User_Exists);
    
    //$row = mysql_fetch_array($User_Exists);
    
    //var_dump($row);
    
    
    $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'", $db_link); 
    
            $exists = mysql_num_rows($User_Exists); 
    
            $row = mysql_fetch_array($User_Exists);
    
             
    
            if($exists > 0) { 
    
            $_SESSION['track_id'] = $row['table_id']; 
    
            $_SESSION['track_name'] = $row['contact_fname']; 
    
             
    
    		echo '<script type="text/javascript">
    			location="home.php"
    		      </script>';
    
             
    
    }else{
    $login_fail="true";
    }
    }
    ?>
    
    
    <html>
    
    	<head>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    		<meta name="generator" content="Adobe GoLive 5">
    		<title>Admin Page :: Login</title>
    	</head>
    
    	<body bgcolor="#ffffff">
    		<div align="center">
    			<font face="Verdana, Arial, Helvetica, sans-serif">Please log in: <br>
    				<br>
    				<? if ($login_fail=="true"){
    				echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>";
    				}
    				?><br>
    				<form name="FormName" action="<?=$PHP_SELF;?>" method="post">
    					<table border="0" cellpadding="0" cellspacing="2" width="180">
    						<tr height="19">
    							<td colspan="2" height="19">
    								<div align="center">
    									<font size="3"><b>
    										
    										Login</b></font></div>
    							</td>
    						</tr>
    						<tr>
    							<td>Username:</td>
    							<td><input type="text" name="username" CLASS="formTextbox" size="24"></td>
    						</tr>
    						<tr>
    							<td>Password:</td>
    							<td><input type="password" name="password" CLASS="formTextbox" size="24"></td>
    						</tr>
    						<tr>
    							<td colspan="2">
    								<div align="center">
    									<input type="submit" CLASS="formTextbox" name="submit" value="Login"></div>
    							</td>
    						</tr>
    					</table>
    				</form>
    			</font></div>
    	</body>
    
    </html>


    with a user and pass not in the database it displays login incorrect

    with a user and pass in the database it takes me to index.php which doesn't exist (i think home.php is supposed to generate index.php with the current users credentials)

    let me give you the long story. this site is for people who are "members" of a sales group. the bosses thaought it would be a good idea for each sales rep to have there own website. we (the it dept) thought it would be better if they used a simple templet. at the time all this went down i was just a pc tech. now i've been thrust into the fast moving world of website stuff.

    I'm going to go beat my head against the wall for a while. If anyone can have a look at this and tell me how to fix it I will forever refer him/her as the the royal highness of php
    Attached Files Attached Files

  4. #29
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No more login problem! Now on to problem number two.
    Getting this error after a successful login.

    Notice: A session had already been started - ignoring session_start() in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/id.php on line 2

    Notice: Undefined variable: row in /Library/Tenon/WebServer/WebSites/www.ABCAdvertising.net/admin/rest_site_creation/id.php on line 4

    Notice: Undefined variable: row in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/id.php on line 5

    Notice: Undefined variable: id in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/home.php on line 43

    Notice: Undefined variable: set_style_id in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/home.php on line 50
    Welcome to your administration panel ID:
    Notice: Undefined variable: id in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/home.php on line 110

    login page mgmt_index.php:
    Code:
    <?php
    session_start();
    //INCLUDES
    include('id.php');
    
    //BEGIN LOGIN
    if($submit || $FrontPage){
    include('db_con.php');
    
    $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'", $db_link);
    		$exists = mysql_num_rows($User_Exists);
    		$row = mysql_fetch_array($User_Exists);
    		
    		//if($exists) {
    	if($exists > 0) { 
    
    		$row = mysql_fetch_array($User_Exists);
    		$_SESSION['track_id'] = $row['table_id'];
    		$_SESSION['track_name'] = $row['contact_fname'];
    		
    		
    		echo '<script type="text/javascript">
    			location="home.php"
    		      </script>';
    		
    }else{
    $login_fail="true";
    }
    }
    ?>
    <html>
    
    	<head>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    		<meta name="generator" content="Adobe GoLive 5">
    		<title>Admin Page :: Login</title>
    	</head>
    
    	<body bgcolor="#ffffff">
    		<div align="center">
    			<font face="Verdana, Arial, Helvetica, sans-serif">Welcome to your administration panel ID: <? echo $id; ?><br>
    				<br>
    				<? if ($login_fail=="true"){
    				echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>";
    				}
    				?><br>
    				<form name="FormName" action="<?=$PHP_SELF;?>" method="post">
    					<table border="0" cellpadding="0" cellspacing="2" width="180">
    						<tr height="19">
    							<td colspan="2" height="19">
    								<div align="center">
    									<font size="3"><b>
    										
    										Login</b></font></div>
    							</td>
    						</tr>
    						<tr>
    							<td>Username:</td>
    							<td><input type="text" name="username" CLASS="formTextbox" size="24"></td>
    						</tr>
    						<tr>
    							<td>Password:</td>
    							<td><input type="password" name="password" CLASS="formTextbox" size="24"></td>
    						</tr>
    						<tr>
    							<td colspan="2">
    								<div align="center">
    									<input type="submit" CLASS="formTextbox" name="submit" value="Login"></div>
    							</td>
    						</tr>
    					</table>
    				</form>
    			</font></div>
    	</body>
    
    </html>

    home.php:
    Code:
    <?php
    session_start();
    error_reporting(E_ALL);
     function copyr($source, $dest)
     {
         // Simple copy for a file
        if (is_file($source)) {
             return copy($source, $dest);
         }
      
         // Make destination directory
         if (!is_dir($dest)) {
             mkdir($dest);
         }
      
         // Loop through the folder
         $dir = dir($source);
         while (false !== $entry = $dir->read()) {
             // Skip pointers
             if ($entry == '.' || $entry == '..') {
                 continue;
             }
      
             // Deep copy directories
             if ($dest !== "$source/$entry") {
                 copyr("$source/$entry", "$dest/$entry");
             }
         }
      
         // Clean up
         $dir->close();
         return true;
     }
    //INCLUDES
    include('id.php');
    include('db_con.php');
    
    
    
    
    
    //CHECK LOGIN VS ID
    if ($id!=$_SESSION['track_id']){
    
    echo '<script type="text/javascript">
    			location="index.php"
    		      </script>';
    		
    }
    if ($set_style_id!=""){
    //GET SITE PATH
    
    $get_root_folder=mysql_query("SELECT root_folder FROM rest_filesystem WHERE rest_id='$id'",$db_link);
    $row=mysql_fetch_array($get_root_folder);
    $root_folder=$row['root_folder'];
    $root_folder_css=($root_folder."/css");
    $root_folder_img=($root_folder."/images");
    
    //GET THEME PATHS
    $get_theme_path=mysql_query("SELECT css_doc FROM styles WHERE style_id='$set_style_id'",$db_link);
    $row=mysql_fetch_array($get_theme_path);
    $theme_path=$row['css_doc'];
    
    $theme_path_css=($theme_path."CSS");
    $theme_path_img=($theme_path."IMAGES");
    
    $index_file=($theme_path."live_index.php");
    
    
    copyr($theme_path_css, $root_folder_css);
    
    copyr($theme_path_img, $root_folder_img);
    
    //CHECK MYSQL FOR ALL PAGES AND NAMES - COPY:
    //copy($index_file, $root_folder."/index.php");
    //TO ALL FILE NAMES CONTAINED
    //AND PUT IN PAGE ID WHERE IT'S SUPPOSED TO GO
    
    		$getpages = mysql_query("SELECT cust_id, pg_id, pg_name, pg_addr FROM rest_pages where cust_id=$id", $db_link);
    								while($row = mysql_fetch_array($getpages)) { 
    									$row['pg_id'] != "";
    									copy($index_file, $root_folder."/".$row['pg_addr']);
    									
    					$page_id=$row['pg_id'];
    
    					$fh = fopen($root_folder."/".$row['pg_addr'], 'r+') or die("can't open file");
    
    					$stringData = '<?php $page_id='. $page_id.';';
    					fwrite($fh, $stringData);
    
    
    					fclose($fh);
    
    }
    
    
    }
    
    ?>
    <html>
    
    	<head>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    		<meta name="generator" content="Adobe GoLive 5">
    		<title>Admin Page :: Home</title>
    	</head>
    
    	<body bgcolor="#ffffff">
    		<div align="center">
    			<font face="Verdana, Arial, Helvetica, sans-serif">Welcome to your administration panel ID: <? echo $id; ?><br>
    				<br>
    				<br>
    				
    					<table border="0" cellpadding="0" cellspacing="2" width="180">
    						<tr height="19">
    							<td colspan="2" height="19">
    								<div align="center">
    								<font size="3"><b>Actions:</b></font></div>
    							</td>
    						</tr>
    						<tr>
    							<td>Select Theme:</td>
    							<td><a href="themes.php">Link</a></td>
    						</tr>
    						<tr>
    							<td>Upload Images:</td>
    							<td><a href="images.php">Link</a></td>
    						</tr>
    						<tr>
    							<td>Manage Pages:</td>
    							<td><a href="pages.php">Link</a></td>
    						</tr>
    						<tr>
    							<td>Change Content:</td>
    							<td><a href="content.php">Link</a></td>
    						</tr>
    						<tr>
    							<td>View Page:</td>
    							<td><a href="../">Link</a></td>
    						</tr>
    						<tr>
    							<td colspan="2">
    								<div align="center">
    								</div>
    							</td>
    						</tr>
    					</table>
    				
    			</font></div>
    	</body>
    
    </html>
    id.php:
    Code:
    <?php
    session_start();
    include('db_con.php');
    $_SESSION['track_id'] = $row['table_id']; 
    $_SESSION['track_name'] = $row['contact_fname'];
    ?>
    It's not storing the variable in id.php
    What am I missing?



    ps i can't thank everyone enough for all the help i've already recieved

  5. #30
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Evening!

    Right then, you can dispense of id.php as you have already assigned the SESSION variables and the session_start()

    After that you should have less errors
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #31
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm Stumped(not that that is hard to do)

    Once logged in my users are presented with a "control panel" where they can select a predefined web templet. New users of course won't have style yet. Any ideas?

    Notice: Undefined variable: set_style_id in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/home.php on line 50

    Code:
    <?php
    session_start();
    error_reporting(E_ALL);
     function copyr($source, $dest)
     {
    * * *// Simple copy for a file
    * * if (is_file($source)) {
    * * * * *return copy($source, $dest);
    * * *}
    * 
    * * *// Make destination directory
    * * *if (!is_dir($dest)) {
    * * * * *mkdir($dest);
    * * *}
    * 
    * * *// Loop through the folder
    * * *$dir = dir($source);
    * * *while (false !== $entry = $dir->read()) {
    * * * * *// Skip pointers
    * * * * *if ($entry == '.' || $entry == '..') {
    * * * * * * *continue;
    * * * * *}
    * 
    * * * * *// Deep copy directories
    * * * * *if ($dest !== "$source/$entry") {
    * * * * * * *copyr("$source/$entry", "$dest/$entry");
    * * * * *}
    * * *}
    * 
    * * *// Clean up
    * * *$dir->close();
    * * *return true;
     }
    //INCLUDES
    include('id.php');
    include('db_con.php');
    
    
    
    
    
    //CHECK LOGIN VS ID
    if ($track_id!=$_SESSION['track_id']){
    
    echo '<script type="text/javascript">
    			location="index.php"
    		* * * </script>';
    		
    }
    //******HERE IS THE PROBLEM***************************************
    if ($set_style_id!=""){
    //****************************************************************
    //GET SITE PATH
    
    $get_root_folder=mysql_query("SELECT root_folder FROM rest_filesystem WHERE rest_id='$id'",$db_link);
    $row=mysql_fetch_array($get_root_folder);
    $root_folder=$row['root_folder'];
    $root_folder_css=($root_folder."/css");
    $root_folder_img=($root_folder."/images");
    
    //GET THEME PATHS
    $get_theme_path=mysql_query("SELECT css_doc FROM styles WHERE style_id='$set_style_id'",$db_link);
    $row=mysql_fetch_array($get_theme_path);
    $theme_path=$row['css_doc'];
    
    $theme_path_css=($theme_path."CSS");
    $theme_path_img=($theme_path."IMAGES");
    
    $index_file=($theme_path."live_index.php");
    
    
    copyr($theme_path_css, $root_folder_css);
    
    copyr($theme_path_img, $root_folder_img);
    
    //CHECK MYSQL FOR ALL PAGES AND NAMES - COPY:
    //copy($index_file, $root_folder."/index.php");
    //TO ALL FILE NAMES CONTAINED
    //AND PUT IN PAGE ID WHERE IT'S SUPPOSED TO GO
    
    		$getpages = mysql_query("SELECT cust_id, pg_id, pg_name, pg_addr FROM rest_pages where cust_id=$id", $db_link);
    								while($row = mysql_fetch_array($getpages)) { 
    									$row['pg_id'] != "";
    									copy($index_file, $root_folder."/".$row['pg_addr']);
    									
    					$page_id=$row['pg_id'];
    
    					$fh = fopen($root_folder."/".$row['pg_addr'], 'r+') or die("can't open file");
    
    					$stringData = '<?php $page_id='. $page_id.';';
    					fwrite($fh, $stringData);
    
    
    					fclose($fh);
    
    }
    
    
    }
    
    ?>
    <html>
    
    	<head>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    		<meta name="generator" content="Adobe GoLive 5">
    		<title>Admin Page :: Home</title>
    	</head>
    
    	<body bgcolor="#ffffff">
    		<div align="center">
    			<font face="Verdana, Arial, Helvetica, sans-serif">Welcome to your administration panel ID: <? echo "$track_id"; ?><br>
    				<br>
    				<br>
    				
    					<table border="0" cellpadding="0" cellspacing="2" width="180">
    						<tr height="19">
    							<td colspan="2" height="19">
    								<div align="center">
    								<font size="3"><b>Actions:</b></font></div>
    							</td>
    						</tr>
    						<tr>
    							<td>Select Theme:</td>
    							<td><a href="themes.php">Link</a></td>
    						</tr>
    						<tr>
    							<td>Upload Images:</td>
    							<td><a href="images.php">Link</a></td>
    						</tr>
    						<tr>
    							<td>Manage Pages:</td>
    							<td><a href="pages.php">Link</a></td>
    						</tr>
    						<tr>
    							<td>Change Content:</td>
    							<td><a href="content.php">Link</a></td>
    						</tr>
    						<tr>
    							<td>View Page:</td>
    							<td><a href="../">Link</a></td>
    						</tr>
    						<tr>
    							<td colspan="2">
    								<div align="center">
    								</div>
    							</td>
    						</tr>
    					</table>
    				
    			</font></div>
    	</body>
    
    </html>

    I've attached the styles table of my database
    Attached Files Attached Files

  7. #32
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    define an empty variable (flag) to be filled at a later date.....

    PHP Code:
    $set_style_id ''
    So when you compare
    if ($set_style_id!=""){
    it has something to compare against.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #33
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just noticed that after I login with a new user the links on the "control panel" (home.php) all take me to index.php which doesn't exist. When I use an existing user the links take me to the correct pages.

    I'm completely lost.

  9. #34
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post
    define an empty variable (flag) to be filled at a later date.....

    PHP Code:
    $set_style_id ''

    spikeZ you are a genius!!!

    Thank You!!!

  10. #35
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by matthewst View Post
    I just noticed that after I login with a new user the links on the "control panel" (home.php) all take me to index.php which doesn't exist. When I use an existing user the links take me to the correct pages.

    I'm completely lost.
    Explain that one again.......
    Quote Originally Posted by matthewst View Post
    spikeZ you are a genius!!!

    Thank You!!!
    Pleasure and thank you
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  11. #36
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, after a user logs into the site they are directed to home.php
    on home.php there is a "control panel" with links that allow a user to upload images and text and things
    if an established user logs in and clicks on of the links in home.php the are taken to the appropriate page
    if a new user logs in and clicks a link on home.php they are directed to index.php which doesn't exist

    I imagine this has something to do with the fact that existing users have a page for the control panel to refer to and new users don't.

  12. #37
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm also having trouble with my image upload and viewing page.

    images.php:
    Code:
    <?php
    session_start();
    //INCLUDES
    include('id.php');
    include('db_con.php');
    
    
    //CHECK LOGIN VS ID
    if ($id!=$_SESSION['track_id']){
    
    echo '<script type="text/javascript">
    			location="index.php"
    		      </script>';
    		
    }
    
    //GET SITE PATH
    $get_root_folder=mysql_query("SELECT root_folder FROM rest_filesystem WHERE rest_id='$id'",$db_link);
    $row=mysql_fetch_array($get_root_folder);
    $root_folder=$row['root_folder'];
    
    $root_folder_img=($root_folder."/images");
    
    
    if($submit) {
    
    //BEGIN PICTURE UPLOAD CODE________________________________________________________________________________*
    
    
    //user defined variables
    $abpath=($root_folder_img); //Absolute path to where images are uploaded. No trailing slash
    $sizelim = "no"; //Do you want size limit, yes or no
    $size = "2500000"; //What do you want size limited to be if there is one
    
    //all image types to upload
    $cert1 = "image/pjpeg"; //Jpeg type 1
    $cert2 = "image/jpeg"; //Jpeg type 2
    $cert3 = "image/gif"; //Gif type
    $cert4 = "image/png"; //PNG type
    
    $log = "";
    
    
    
    //==================================================================begin upload 1===============================================================
    
    //checks if file exists
    if ($img1_name == "") {
    $log .= "No file selected for upload 1<br>";
    }
    if ($img1_name != "") {
    
    
    $image1nameext = $img1_name;
    if ($image1nameext!=""){
    //Checks if file is an image
    if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3) or ($img1_type == $cert4) or($img1_type == $cert5)) {
    if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3) or ($img1_type == $cert4)) {
    if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3)) {
    if (($img1_type == $cert1) or ($img1_type == $cert2)) {
    
    }
    if ($img1_type == $cert3) {
    
    }
    if ($img1_type == $cert4) {
    
    }
    if ($img1_type == $cert3) {
    
    }
    }
    }
    @copy($img1, "$abpath/$image1nameext") or $log .= "Couldn't copy file 1 to server - it may be too large, or the transfer may have been disrupted<br>";
    
    if (file_exists("$abpath/$image1nameext")) {
    
    $log .= "File 1 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> &lt;img src=&quot;images/$image1nameext&quot;&gt;</font><br>into any content area.<br><br>";
    }
    } else {
    $log .= "File 1 is not an image$img1_name<br>";
    }
    }
    }
    
    
    
    //==================================================================begin upload 2===============================================================
    //checks if file exists
    if ($img2_name == "") {
    $log .= "No file selected for upload 2<br>";
    }
    if ($img2_name != "") {
    
    
    $image2nameext = $img2_name;
    if ($image2nameext!=""){
    //Checks if file is an image
    if (($img2_type == $cert1) or ($img2_type == $cert2) or ($img2_type == $cert3) or ($img2_type == $cert4) or($img2_type == $cert5)) {
    if (($img2_type == $cert1) or ($img2_type == $cert2) or ($img2_type == $cert3) or ($img2_type == $cert4)) {
    if (($img2_type == $cert1) or ($img2_type == $cert2) or ($img2_type == $cert3)) {
    if (($img2_type == $cert1) or ($img2_type == $cert2)) {
    
    }
    if ($img2_type == $cert3) {
    
    }
    if ($img2_type == $cert4) {
    
    }
    if ($img2_type == $cert3) {
    
    }
    }
    }
    @copy($img2, "$abpath/$image2nameext") or $log .= "Couldn't copy file 2 to server - it may be too large, or the transfer may have been disrupted<br>";
    
    if (file_exists("$abpath/$image2nameext")) {
    
    $log .= "File 2 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> &lt;img src=&quot;images/$image2nameext&quot;&gt;</font><br>into any content area.<br><br>";
    }
    } else {
    $log .= "File 2 is not an image$img1_name<br>";
    }
    }
    }
    
    
    //==================================================================begin upload 3===============================================================
    
    
    
    
    //checks if file exists
    if ($img3_name == "") {
    $log .= "No file selected for upload 3<br>";
    }
    if ($img3_name != "") {
    
    
    $image3nameext = $img3_name;
    if ($image1nameext!=""){
    //Checks if file is an image
    if (($img3_type == $cert1) or ($img3_type == $cert2) or ($img3_type == $cert3) or ($img3_type == $cert4) or($img3_type == $cert5)) {
    if (($img3_type == $cert1) or ($img3_type == $cert2) or ($img3_type == $cert3) or ($img3_type == $cert4)) {
    if (($img3_type == $cert1) or ($img3_type == $cert2) or ($img3_type == $cert3)) {
    if (($img3_type == $cert1) or ($img3_type == $cert2)) {
    
    }
    if ($img3_type == $cert3) {
    
    }
    if ($img3_type == $cert4) {
    
    }
    if ($img3_type == $cert3) {
    
    }
    }
    }
    @copy($img3, "$abpath/$image3nameext") or $log .= "Couldn't copy file 3 to server - it may be too large, or the transfer may have been disrupted<br>";
    
    if (file_exists("$abpath/$image3nameext")) {
    
    $log .= "File 3 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> &lt;img src=&quot;images/$image3nameext&quot;&gt;</font><br>into any content area.<br><br>";
    }
    } else {
    $log .= "File 3 is not an image$img3_name<br>";
    }
    }
    }
    
    
    
    
    //==================================================================begin upload 4===============================================================
    
    
    
    //checks if file exists
    if ($img4_name == "") {
    $log .= "No file selected for upload 4<br>";
    }
    if ($img4_name != "") {
    
    
    $image4nameext = $img4_name;
    if ($image4nameext!=""){
    //Checks if file is an image
    if (($img4_type == $cert1) or ($img4_type == $cert2) or ($img4_type == $cert3) or ($img4_type == $cert4) or($img4_type == $cert5)) {
    if (($img4_type == $cert1) or ($img4_type == $cert2) or ($img4_type == $cert3) or ($img4_type == $cert4)) {
    if (($img4_type == $cert1) or ($img4_type == $cert2) or ($img4_type == $cert3)) {
    if (($img4_type == $cert1) or ($img4_type == $cert2)) {
    
    }
    if ($img4_type == $cert3) {
    
    }
    if ($img4_type == $cert4) {
    
    }
    if ($img4_type == $cert3) {
    
    }
    }
    }
    @copy($img4, "$abpath/$image4nameext") or $log .= "Couldn't copy file 4 to server - it may be too large, or the transfer may have been disrupted<br>";
    
    if (file_exists("$abpath/$image4nameext")) {
    
    $log .= "File 4 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> &lt;img src=&quot;images/$image4nameext&quot;&gt;</font><br>into any content area.<br><br>";
    }
    } else {
    $log .= "File 4 is not an image$img4_name<br>";
    }
    }
    }
    
    
    
    //==================================================================begin upload 5===============================================================
    
    
    
    //checks if file exists
    if ($img5_name == "") {
    $log .= "No file selected for upload 5<br>";
    }
    if ($img5_name != "") {
    
    
    $image5nameext = $img5_name;
    if ($image5nameext!=""){
    //Checks if file is an image
    if (($img5_type == $cert1) or ($img5_type == $cert2) or ($img5_type == $cert3) or ($img5_type == $cert4) or($img5_type == $cert5)) {
    if (($img5_type == $cert1) or ($img5_type == $cert2) or ($img5_type == $cert3) or ($img5_type == $cert4)) {
    if (($img5_type == $cert1) or ($img5_type == $cert2) or ($img5_type == $cert3)) {
    if (($img5_type == $cert1) or ($img5_type == $cert2)) {
    
    }
    if ($img5_type == $cert3) {
    
    }
    if ($img5_type == $cert4) {
    
    }
    if ($img5_type == $cert3) {
    
    }
    }
    }
    @copy($img5, "$abpath/$image5nameext") or $log .= "Couldn't copy file 5 to server - it may be too large, or the transfer may have been disrupted<br>";
    
    if (file_exists("$abpath/$image5nameext")) {
    
    $log .= "File 5 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> &lt;img src=&quot;images/$image5nameext&quot;&gt;</font><br>into any content area.<br><br>";
    }
    } else {
    $log .= "File 5 is not an image$img5_name<br>";
    }
    }
    }
    
    
    
    //END PICTURE UPLOAD CODE__________________________________________________________________________________*
    }
    ?>
    <html>
    
    	<head>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    		<meta name="generator" content="Adobe GoLive 5">
    		<title>Admin Page :: Images</title>
    	</head>
    
    	<body bgcolor="#ffffff">
    		<div align="center">
    			<font face="Verdana, Arial, Helvetica, sans-serif">Welcome to your administration panel ID: <? echo "$track_id"; ?><br>
    				<? echo $log; ?><br>
    				<br>
    				<table border="0" cellpadding="0" cellspacing="2" width="600">
    					<form action="<?=$PHP_SELF;?>" method="post" enctype="multipart/form-data" name="FormName">
    						<tr height="19">
    							<td colspan="2" height="19">
    								<div align="center">
    									<font size="3"><b>Upload New Pictures:</b></font></div>
    							</td>
    						</tr>
    						<tr>
    							<td valign="top" width="150"><b>You may upload up to five pictures at a time.<input type="hidden" value="<?=$project;?>" name="project"><input type="hidden" value="hiddenValue" name="hiddenName"></b></td>
    							<td>
    								<p>Pictures to upload:<br>
    									<input type=file name=img1 size=30><br>
    									<input type=file name=img2 size=30><br>
    									<input type=file name=img3 size=30><br>
    									<input type=file name=img4 size=30><br>
    									<input type=file name=img5 size=30><br>
    								</p>
    							</td>
    						</tr>
    						<tr>
    							<td colspan="2">
    								<div align="center">
    									<input type="submit" name="submit" value="Upload"></div>
    							</td>
    						</tr>
    					</form>
    				</table>
    			</font><font face="Verdana, Arial, Helvetica, sans-serif"><br>
    				<?php
     $mydir = ("$root_folder/images");
     //$mydir = dir("rest/MattsBBQ_603/images") 
    
    
    ?><br>
    			</font><font face="Verdana, Arial, Helvetica, sans-serif">
    			<table width="650" border="0" cellspacing="2" cellpadding="0">
    				<tr>
    					<td colspan="3" align="center"><b>Your Pictures:</b><br>
    							<font size="-2">Click to enlarge.</font></td>
    				</tr>
    				
    				<?php while(($file = $mydir->read()) !== false) {
    
    
          if($file==".") {
           }else{
          if($file==".."){
          }else{
          if($file==".DS_Store"){
         }else{ 
            echo "<tr><td align='center'>$file</td></tr><tr><td align='center'><a href='../images/$file' target='_blank'><img width='150' border='0' src='../images/$file'></a></td></tr><tr><td align='center'>&lt;img src=&quot;images/$file&quot;&gt;</td></tr>";
             }
             }
          }
       }
       $mydir->close();?>
    					
    				
    			</table>
    				<br>
    				
    				
    				
    			</font><font face="Verdana, Arial, Helvetica, sans-serif"><br>
    				<a href="home.php">Admin Home</a></font></div>
    	</body>
    
    </html>
    It keeps giving me this error:
    Code:
    Fatal error: Call to a member function read() on a non-object in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/images.php on line 324
    line 324 is:
    Code:
    <?php while(($file = $mydir->read()) !== false) {
    php is great but i'm going to go punch myself in the groin for a little while. it's less painful.
    Last edited by matthewst; Apr 17, 2007 at 07:40. Reason: i'm retarded


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •