Jump to content

gilestodd

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Posts posted by gilestodd

  1. I've got a deleting images function I picked up from a forum post on here:

     

    http://www.phpfreaks.com/forums/index.php?topic=244816.0&fb_source=message

     

    But im getting this error when I delete an image.

     

    Warning: unlink(img.jpg) [function.unlink]: No such file or directory in /home/s519970/public_html/admin/deletecontent.php on line 20

     

    The image gets deleted but im just assuming its looking for it again and not finding it. Could anyone advise me on how to remove this error?

  2. Im using this code to call all the images in a folder:

     

    $handle = opendir(dirname(realpath(__FILE__)).'/images/');
    	while($file = readdir($handle)){
    		if($file !== '.' && $file !== '..'){
    			echo '<img src="admin/img/uploads/'.$file.'" border="0" />';
    		}
    	}

     

    My html says the images are present but they aren't visable on screen:

     

    <div id="contentbody">
    <img src="admin/img/uploads/send-button-sprite copy.png" border="0" />
    <img src="admin/img/uploads/test" border="0" />
    <img src="admin/img/uploads/counter.jpg" border="0" />
    <img src="admin/img/uploads/send-button-sprite.png" border="0" />
    </div>

     

    Any help is much appreciated!

  3. I am having trouble resolving an error.

     

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/s519970/public_html/header.php:27) in /home/s519970/public_html/admin/login.php on line 2

     

    What I can gather is I can't use "header (Location: 'admin.php')" after i've used session_start(). I have tried to replace the header (Location: 'admin.php') with this:

     

                    echo "<script>document.location.href='admin.php'</script>";

    echo "<script>'Content-type: application/octet-stream'</script>";

     

    I've been trying to read up on solutions but haven't been able to get it sorted. If anyone can offer some advice that would be greatly appreciated as im new to php.

     

    <?php
      session_start();
      if(isset($_SESSION['user']))
    
                    echo "<script>document.location.href='admin.php'</script>";
    	echo "<script>'Content-type: application/octet-stream'</script>";
    ?>
    
    <div id="loginform">
    
    <form action="dologin.php" method="post">
    	<table>
    		<tr>
    			<td><span>Username:</span></td>
    			<td><input type="text" name="username" /></td>
    		</tr>
    		<tr>
    			<td><span>Password:</span></td>
    			<td><input type="password" name="password" /></td>
    		</tr>
    		<tr>
    			<td colspan="2" align="right"><input type="submit" name="login" value="Login" /></td>
    		</tr>
    	</table>
    </form>
    
    </div>

     

    I have tried using require_once('yourpage.php'); before my <head></head> tags in the header document where I've specified the html information but this doesn't seem to work. I've been advised to use ob_start("ob_gzhandler"); but I am not sure how to implement this.

     

    Any advice is greatly appreciated!

     

  4. How would I redirect them to the page they're currently on when entering data into the comments box. I've included the file with the comments box in on multiple pages so can't redirect them to a specific page as it might not be the one they were on initially.

     

    <?php
    require('commentconnect.php');
    $name=@$_POST['name'];
    $comment=@$_POST['comment'];
    $submit=@$_POST['submit'];
    if($submit)
    {
    if($name&&$comment)
    {
    	$insert=mysql_query("INSERT INTO commenttable (name,comment) VALUES ('$name','$comment')");
    	/*header("Location: index.php");*/
    	echo "<script>document.location.href='index.php'</script>";
    	echo "<script>'Content-type: application/octet-stream'</script>";
    	}
    else
    {
    	echo "Please fill out the fields";
    }
    }
    ?>
    
    <div id="commentdiv">
    
    <div id="commentinput">
    
    <form action="index.php" method="POST">
    <table>
    	<tr><td>Name: </td><td><input type="text" name="name" /></td></tr>
    	<tr><td colspan="2">Comment: </td></tr>
    	<tr><td colspan="2"><textarea name="comment"></textarea></td></tr>
    	<tr><td colspan="2"><input type="submit" name="submit" value="Comment" /></td></tr>
    
    </table>
    </form>
    
    </div>
    
    <div id="commentarea">
    <?php
    $sql = "SELECT * FROM commenttable ORDER BY id DESC";
    if ($getquery = mysql_query($sql)) {
    while ($rows=mysql_fetch_array($getquery)) {
    
    $id=$rows['id'];
    $name=$rows['name'];
    $comment=$rows['comment'];
    $dellink="<a href=\"delete.php?id=" . $id . "\"></a>";
    
    echo $name . '' . '<br />' . $comment . '<br />' . '<hr/>';
    }
    }
    else {
    	trigger_error(mysql_error());
    }
    ?>
    
    </div>
    
    </div>

     

    This is the included comments box page.

  5. I am trying to install a comments box, im new to php and mysql so havent been able to work this out for myself following other threads, hope someone can shed some light on the problem.

     

    The posts ive entered arent being returned to the page essentially and im getting the error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in commentbox.php on line 42.

     

    This is the code from the entire page.

     

    <?php
    require('commentconnect.php');
    $name=@$_POST['name'];
    $comment=@$_POST['comment'];
    $submit=@$_POST['submit'];
    if($submit)
    {
    if($name&&$comment)
    {
    	$insert=mysql_query("INSERT INTO commenttable (name,comment) VALUES ('$name','$comment')");
    	/*header("Location: index.php");*/
    	echo "<script>document.location.href='index.php'</script>";
    	echo "<script>'Content-type: application/octet-stream'</script>";
    	}
    else
    {
    	echo "Please fill out the fields";
    }
    }
    ?>
    
    <div id="commentdiv">
    
    <div id="commentinput">
    
    <form action="index.php" method="POST">
    <table>
    	<tr><td>Name: </td><td><input type="text" name="name" /></td></tr>
    	<tr><td colspan="2">Comment: </td></tr>
    	<tr><td colspan="2"><textarea name="comment"></textarea></td></tr>
    	<tr><td colspan="2"><input type="submit" name="submit" value="Comment" /></td></tr>
    
    </table>
    </form>
    
    </div>
    
    <div id="commentarea">
    
    <?php
    $getquery=mysql_query("SELECT * FROM commenttable ORDER BY id DESC");
    while($rows=mysql_fetch_array($getquery))	
    {
    $id=$rows['id'];
    $name=$rows['name'];
    $comment=$rows['comment'];
    $dellink="<a href=\"delete.php?id=" . $id . "\"> Delete </a>";
    echo $name . '' . '<br />' . $comment . '<br />' . '<hr/>';
    } 
    ?>
    </div>
    
    </div>
    

     

    Any help is greatly appreciated!

  6. I see, got that sorted, been succesfully redirected to my index.php page. However, im not veiwing any of my content.

     

    <html>
    <head>
    <title>Basic CMS - Admin Area</title>
    </head>
    <body>
    
    <?php
    session_start();
    if(isset($_SESSION['user']))
      header("Location: admin/login.php");
    ?>
    
    <span>Logged In! Welcome <?php> echo $_SESSION['user']; ?></span>
    
    <a href="logout.php">Logout</a>
    <a href="posts.php">Manage Posts</a>
    
    <p>This is some test text...</p>
    
    </body>
    </html>
    

     

     

    Nothing is visable on screen, not even the test text I put in <p></p> tags, any advice on this one?

     

    Thanks for the help.

  7. I need help getting my login form to redirect to my admin area. I have been following tutorials on youtube trying to create a content management system and have made it as far as creating the form and creating the login action required to look for a username and password form my database and log in. I'll post up the pages I think are required for someone to give me some advice on where im going wrong.

     

    my login page

     

    login.php

    <html>
    <head>
    <title>Basic CMS - Admin Area - Login</title>
    </head>
    <body>
    
    <?PHP
      session_start();
      if(isset($_SESSION['user']))
         header("Location: index.php");
    ?>
    <form action="dologin.php" method="post">
    	<table>
    		<tr>
    			<td><span>Username:</span></td>
    			<td><input type="text" name="username" /></td>
    		</tr>
    		<tr>
    			<td><span>Password:</span></td>
    			<td><input type="password" name="password" /></td>
    		</tr>
    		<tr>
    			<td colspan="2" align="right"><input type="submit" name="login" value="Login" /></td>
    		</tr>
    	</table>
    </form>
    </body>
    </html>
    

     

    my login actions page

     

    dologin.php

    <?php
    include('includes/functions.php');
    session_start();
    
    if (isset($_POST['login'])) {
    if(isset($_POST['username'])) {
    	if(isset($_POST['password'])) {
    
    		$username = $_POST['username'];
    		$query = mysql_query("SELECT * FROM users WHERE Username = '$username'") or die (mysql_error());
    		$user = mysql_fetch_array($query);
    
    		if(md5($_POST['password']) == $user['Password']) {
    			echo "Login successful";
    			$_SESSION['user'] = $user['Username'];
    			header("Location: index.php");
    		} else {
    
    			echo "Please check your login details!";
    			include('login.php');
    		}			
    	} else {
    		echo "Please check your password!";
    		include('login.php');
    	}
    } else {
    	echo "Please check your username!";
    	include('login.php');
    }
    } else {
    echo "Please check that you filled out the login form!";
    include('login.php');
    }
    ?>

     

    and my admin area

     

    index.php

    <?php
    session_start();
    if(!isset($_SESSION['user']))
      header("Location: admin/login.php");
    ?>
    
    <html>
    <head>
    <title>Basic CMS - Admin Area</title>
    </head>
    <body>
    
    <span>Logged In! Welcome <?php> echo $_SESSION['user']; ?></span>
    
    <a href="logout.php">Logout</a>
    <a href="posts.php">Manage Posts</a>
    
    </body>
    </html>
    

     

     

    On logging in I am given "Login succesful" on the dologin.php page but I need it to redirect me to my index.php page, which is my admin area. If there's any other information you need to help me out just let me know.

     

    Any help anyone has for me is greatly appreciated! Thank you in advance.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.