Jump to content

Multiple Issues


walkonet

Recommended Posts

Hi Again!

 

using wamp 1.7 php 5 mysql 5

 

Well First off My  1st php site is almost done....

http://mattwalko.phpnet.us/Essence/index.php

 

Most of my problems are from my index page....

<?php 

//Address Error Handling
ini_set('display_errors', 1);
error_reporting( E_ALL & E_NOTICE);

//DEFINE page title and include the header
define('TITLE', 'Matt-Walko: HOME');
require('./includes/header.inc'); 

?>

<!--START OF MAIN BODY CONTENT -->
<?php //Script 3.0 Display Entries
	//This  script displays blog entries in DESC order.

	//address error handling
	ini_set ('display_errors', 1);
	error_reporting (E_ALL & ~E_NOTICE);

		//Connect and select
		require_once ("./connect/dbc.php");


		//Define the query
		$query = 'SELECT * FROM posts ORDER BY date_entered DESC'; 
		if ($r = mysql_query ($query)) { //Run Query

			$time = date('h:i m/d/y', $row['date_entered']);

			//Retrieve and print every record.
			while ($row = mysql_fetch_array ($r)) {
				print "
				<h1>{$row['title']}</h1>
				{$row['entry']}<br />
				<p class=\"date\">Posted by {$row['author']} <img src=\"./img/more.gif\" alt=\"\" /> 
				<a href=\"redmor.php?rm={$row['post_id']}\">Read more</a> <img src=\"./img/comment.gif\" alt=\"\" /> 
				<a class=\"comment\" href=\"comment.php?id={$row['post_id']}\">Comments (?)</a> 
				<img src=\"./img/timeicon.gif\" alt=\"\" />  $time</p><br />";
			}

		} else { //query didnt run

			die ('<p>Could not retieve the data because: <b>' . mysql_error() . "</b>. 
			The query was $query.</p>");
		} // end of IF query.

		mysql_close();

		?>

<h1>RedBridge Template</h1>
	Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer euismod ante non diam. Sed eleifend odio sed quam. Sed vulputate, <a
	href="#">turpis at tincidunt</a>  porttitor, est elit consequat metus, non dignissim augue mauris quis arcu. Phasellus faucibus blandit eros. Curabitur porttitor ante non est. Maecenas dolor. Aenean egestas sem. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Sed suscipit, nisi sit amet pharetra malesuada, sem velit laoreet sem, vitae iaculis diam neque consequat est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque tincidunt eros non quam. Mauris a magna sit amet libero accumsan auctor. Aenean nec urna non dui lobortis viverra.
	<p class="date">Posted by Avenir <img src="./img/more.gif" alt="" /> <a href="#">Read more</a> <img src="./img/comment.gif" alt="" /> <a href="#">Comments(2)</a> <img src="./img/timeicon.gif" alt="" /> 21.02.</p><br />

	<blockquote><p>Luctus vitae, dolor. Nunc mauris eros, vehicula id, fermentum non, semper ac, nisl. Cras sed purus non justo lobortis rhoncus. Morbi consectetuer augue</p></blockquote>

	<p>Luctus vitae, dolor. Nunc mauris eros, vehicula id, fermentum non, semper ac, nisl. Cras sed purus non justo lobortis rhoncus. Morbi consectetuer augue.</p>

</div>

<!--END OF MAIN BODY CONTENT -->
<?php 

require('./includes/footer.inc'); 

?>

 

My first issue:

I'm trying to format the timestamp from each post but its comming out as "07:00 12/31/69" on all post...

 

Second Issue:

I'm trying to come up with a way to limit the number of posts that come up on the index page. I tried taking an excerpt from the pagination  code but it didnt work.

 

Third Issue:

This one for the admin area. I tried and tried to figure out sessions but I just cant seem to get it to work on my site. and when it rediects what do i use to keep my area protected?

 

<?php 

//Address Error Handling
ini_set('display_errors', 1);
error_reporting( E_ALL & E_NOTICE);

//DEFINE page title and include the header
define('TITLE', 'Matt-Walko: LOGIN');
require('./includes/header.inc'); 

?>
<!--START OF MAIN BODY CONTENT -->
<?php
print '<h1>Login Form</h1> <p>enter in username and password to gain entry.</p>';

//check if form has been submitted
if (isset($_POST['submitted'])) {

	//handle form values
 if ( (!empty ($_POST['username'])) && (!empty ($_POST['password'])) ) {
	if ( ($_POST['username'] == 'testing') && ($_POST['password'] == 'testpass') ) {

		//session stuff
		session_start();
		$_SESSION['username'] = 'testing';
		$_SESSION['loggedin'] = time();

		//redirect
		header ('Location: admin.php');
		exit();

		} else {
			print '<p>The username password does not match those on file.</p>';
	} else {
		print '<p>Please make sure you enter in both a username and a password.</p>';
	}
} else {

	//display the form
	print '<form action="login.php" method="post"><p>
			Username: <input type="text" name="username" size="30" /><br />
			Password: <input type="password" name="password" size="30" /><br />
			<input type="submit" name="submitted" value="Log In" /></p>
			</form>';
}
?>
<!--END OF MAIN BODY CONTENT -->
<?php 

require('./includes/footer.inc'); 

?>

 

If anyone can help my resolve any of these issues. I would appreciate it.

Link to comment
Share on other sites

My first issue:

I'm trying to format the timestamp from each post but its comming out as "07:00 12/31/69" on all post...

in that case your not inserting the correct time

 

Second Issue:

I'm trying to come up with a way to limit the number of posts that come up on the index page. I tried taking an excerpt from the pagination  code but it didnt work.

but it didnt work.
?? not helpful, try fixing it
Link to comment
Share on other sites

for the session issue. I insert the user/pass it throughs up the 2 elses: please insert both a username and password and user/pass doesnt match those on file.

 

in that case your not inserting the correct time

what do i use to fix that?

 

 

Link to comment
Share on other sites

thanks but i rewrote the query and got the result i wanted.

$query = "SELECT post_id, author, category, title, entry, DATE_FORMAT(date_entered, '%b %d, %y @ %h:%i %p') AS D FROM 
		posts ORDER BY date_entered DESC";

 

just wondering anyone got any ideas on how to limit the number of post that are displayed with using pagenation?

 

UPDATE: Issues, 1, and 2 ARE RESOLVED

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.