Jump to content

walkonet

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

About walkonet

  • Birthday 01/01/1981

Contact Methods

  • MSN
    m.walk.o@hotmail.com

Profile Information

  • Gender
    Male
  • Location
    ohio,usa

walkonet's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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
  2. 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. what do i use to fix that?
  3. 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.
  4. Hello everyone! I am using WAMP SERVER 1.7.2 with PHP ver: 5.2.3 and MYSQL ver: 5.0.41-community-nt Im trying to get a comments form to submit the comment and carry on the post id that the comment is for... Its like a blog script... the admin writes the the post, post is displayed in index page, from the i pass on the post id to the comments form, the user enters in their name, email and comment, form submitted with their name, email, entry, timestamp, and the post id for which the comment is for... My trouble is im not entirely sure how im supposed to query the DB for the insertion, and how to query the DB to call up the specific post? Also im not sure how to go from there once im done with that... e.g. from the query to displaying the form.... heres the code: VERSION 1 <?php #script - Edit Existing Records from PHP and MYSQL for Dynamic Websites pg. 289. /* //check for a valid ID, through GET or POST if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { //accessed through view_posts.php $id = $_GET['id']; }elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { //accessed through view_posts.php $id = $_POST['id']; } else { //no valid ID or not reading it from view_posts.php. echo '<p><strong>Either there was NO ID to pull or Something didnt get passed through <i>view_users.php</i></strong></p>'; } */ require_once ('./connect/dbc.php'); //Connect to the db. //Check if the form has been submitted if (isset($_POST['submitted'])) { //submit conditional if ($_POST['sure'] == 'Yes') { //add comment //Define the query $query = "INSERT INTO comments (comment_id, post_id={$_GET['id']}, name, email, entry, date_entered) VALUES (0, '{$_GET['id']}', '{$_POST['name']}', '{$_POST['email']}', '{$_POST['entry']}, NOW())"; //Retrieve the post's details $query1 = "SELECT * FROM posts WHERE post_id=$id"; //Execute the query if (@mysql_query ($query1)) { print '<p>The blog entry has been added.</p>'; } else { print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } } } //end of main submit conditional mysql_close(); ?> <form class="form" action="comment.php" method="post"> <table align="center" width="90%" border="0" cellspacing="0" cellpadding="0"> <caption align="top"> ADD A COMMENT </caption> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th align="right" scope="row">name:</th> <td><input type="text" name="name" size="40" maxsize="100" /></td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th align="right" scope="row">email:</th> <td><input type="text" name="email" size="40" maxsize="100" /></td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th valign="top" align="right" scope="row">POST:</th> <td><textarea name="entry" cols="40" rows="10"></textarea></td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> <input type="submit" name="submit" value="Add the Comment!" /> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="{$_GET['id']}" /> </td> </tr> </table> </form> VERSION 2 <?php #script - Add comment to specific post //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); //Check if the form has been submitted if (isset($_POST['submitted'])) { //submit conditional if ($_POST['sure'] == 'Yes') { //add comment //Define the query $query = "INSERT INTO comments (comment_id, post_id={$_GET['id']}, name, email, entry, date_entered) VALUES (0, '{$_GET['id']}', '{$_POST['name']}', '{$_POST['email']}', '{$_POST['entry']}, NOW())"; } else { //report on insertion if (mysql_affected_rows () == 1) { print '<p>The comment has been added.</p>'; } else { print "<p>Could not be added because: " . mysql_error() . ". The query was $query."; //check for a valid ID, through GET or POST if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { //accessed through view_posts.php $id = $_GET['id']; }elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { //accessed through view_posts.php $id = $_POST['id']; } else { //Retrieve the post's details $sql = "SELECT post_id FROM posts WHERE post_id=$id"; if ($r = mysql_query ($sql)) { //Run Query //print form with the post id in hidden form input while ($row = mysql_num_rows ($r)) { print " <form class=\"form\" action=\"comment.php\" method=\"post\"> <table align=\"center\" width=\"90%\" border="0" cellspacing="0" cellpadding="0"> <caption align=\"top\"> ADD A COMMENT </caption> <tr> <th scope=\"row\"> </th> <td> </td> </tr> <tr> <th align=\"right\" scope=\"row\">name:</th> <td><input type=\"text\" name=\"name\" size="40" maxsize="100" /></td> </tr> <tr> <th scope=\"row\"> </th> <td> </td> </tr> <tr> <th align=\"right\" scope=\"row\">email:</th> <td><input type=\"text\" name=\"email\" size="40" maxsize="100" /></td> </tr> <tr> <th scope=\"row\"> </th> <td> </td> </tr> <tr> <th valign=\"top\" align=\"right\" scope=\"row\">POST:</th> <td><textarea name=\"entry\" cols="40" rows="10"></textarea></td> </tr> <tr> <th scope=\"row\"> </th> <td> </td> </tr> <tr> <th scope=\"row\"> </th> <td> <input type=\"submit\" name=\"submit\" value=\"Add the Comment!\" /> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> <input type=\"hidden\" name=\"id\" value=\"{$_GET['id']}\" /> </td> </tr> </table> </form>"; } 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. } } else { echo '<p><strong>Either there was NO ID to pull or Something didnt get passed through <i>view_users.php</i></strong></p>'; } } mysql_close(); ?> *note that only the script is showing.* Thank you in advance for any help!!!!
  5. or maby you could set the pay slips up to display one payslip per page with pageination. and have some way to select which payslip you want....
  6. im a little confused... are you talking about how to make your own post and displaying them in your CMS?
  7. I'm soo sorry for the really bad post firrst of all. I was really tired and couldn't explain the issue propery. What I want to to is on the main page (index.php) show a list of posts i have made. Along with that I want an option to post a comment to the specific post. What im not shure about is how i should set up my database table for the comments. Here's what I am thinking: DB: MWBlog TABLE: comments FIELDS: comment_id, nick, ((optional->)email, ,website), entry Now for the comment page: (this is where i need advise) Setup a link somehow that will let the user post a comment to the specific post id and either have the comment(s) posted on that page, or on another page with the original post at the top? I not even shure that would be the best way to do it and i have no idea how to accomplish it. The only thing i know how to do so far to help me accomplish this ( I think ) is passing the id to the target script for record insertion. And if thats how I do it then would i use the post_id as the var to pss on or comment var in the link that would take the user to the script that allows the visitors to post thier comment? (e.g. http://somedomain.com/index.php?id=(post_id) or http://somedomain.com/index.php?cid=(comment_id) also do I just make a simple record insertion page for the comments? And if I do that how am i supposed to display the comments for the specific post? The only way I can think of is using left join and i really dont understand it... I've read about it in three different books and saw some examples but still it's not clicking for me. Im proably making this alot harder than it really is im just not shure how to go about it or even make the first step.
  8. Hey everyone! I've been working on a CMS of sorts and i got alot done but i cant figure out how to set up my DB for comments... Let me explain. on my main page I have a list of posts with view comment link and a add comments link. but really i just want a link like this (# of comments) COMMENTS which would take the user to a comments page that displays the comments already there and let them post new ones. im extremely confused on how i should structure this..... here's what i have done: http://mattwalko.phpnet.us/MWBlog/index.php *please note that its only half done* but i hope someone could point me in the right direction structurally speaking to accomplish a stupid comment script... I mean i think it should work off of the post id ? e.g. "view_posts.php?id=6" and somehow transfer the id of the post to the add comments page? and should i be using joins in the DB to accomplish this stuff? lmoa im really confuzed!!! any help or pointer in the direction would be great. and btw if you havent figured it out im pretty new to php lol i thought about somehow changing "view_posts.php?id=6" to "view_posts.php?cid=6" and joining the post id and the new comment id... but im probably way off.... BTW on my site admin panel works (*not manage comments*), and archives
  9. your post is a little hard to follow... but if i get you right you essentially need a pm system like boards have? and some where displaying thier information? if thats what your after, and you dont know anything about php? or mysql? the best thing i could do for you is suggest googling a blog tutorial (coding it...) because it will show you how to set up a comment box, store it in the database and how to retrieve it where you need it... which is what a pm system is... also your gonna need to research forms, and recordset? i think its called... anyways what i mean is you need to understand how to send information to the database through variables via a html form and where and how to retrieve it.... I mentioned this because it didnt seem like you knew anything about php and mysql. If you already knew this sorry for the misunderstnding... and i hope this helped.
  10. EDIT*** it works now. Forgot to remove a bracket.... lol thanks.....
  11. did you add the # to textarea style? i.e #textarea or .textarea? and the color is set to black? (#000000) try #333333 or grey...
  12. ok... I made a login page that is supposed to test the email and password of a registered user. once that is accomplished it is supposed to redirect the user to the loggedin.php page which it does not. however if you type in loggedin.php after you enter in the required info it print out perfectly??? my site if you would like to see the problem in action is [url=http://walkonet.com/test/login.php]http://walkonet.com/test/login.php[/url] test acount info: asd@asd.com/clown123 hit ok and then in the URL type in loggedin.php and see the result... here the login script: [code] <?php # user login - login.php //send nothing to the browser befor the setcookie() lines function escape_data ($data) { global $dbc; //Need the connection if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } return mysql_real_escape_string(trim($data),$dbc); } // End of Function //check if the form has been submitted if(isset($_POST['submitted'])) { require_once('./connect/mysql_connect.php'); $errors = array(); //Check for an email. if (empty($_POST['email'])) { $errors[] = 'You forgot to enter an E-mail address.'; } else { $e = escape_data($_POST['email']); } //Check for an email. if (empty($_POST['password'])) { $errors[] = 'You forgot to enter a password.'; } else { $p = escape_data($_POST['password']); } if(empty($errors)) {//<-- its ok /*retrive the user id and first name for that email/passord combonation */ $query = "SELECT user_id, first_name FROM users WHERE email='$e' AND password=SHA('$p')"; $result = @mysql_query($query); $row = mysql_fetch_array($result, MYSQL_NUM); //return a record, if applicable if($row){ //a record was pulled from the database. //set cookies and redirect. setcookie('user_id', $row[0]); setcookie('first_name', $row[1]); //redirct user to logged in page. loggedin.php //start defining the URL $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); //check for trailing slash. if((substr($url, -1) == '/') or (substr($url, -1) == '\\')) { $url = substr($url, 0, -1); //chop off the slash     } //add the page. $url .='/loggedin.php'; } else { //no record was found $errors[] ='The E-mail/Password combonation does not match those on file.'; //public message $errors[] = mysql_error() . '<br /><br />Query: ' . $query; //debug msg } } //end of if (empty($errors)) IF mysql_close(); } else {//form has not been submitted $errors = NULL; } //end of main submit conditional //begin the page now. $page_title = 'Login'; include('./includes/header.html'); if(!empty($errors)) { //print all errors echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach($errors as $msg) { //print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p>'; } //create the form ?> <h2>Login</h2> <form action="login.php" method="post"> <p>E-mail Address: <input type="text" name="email" size="20" maxlength="40" /></p> <p>Password: <input type="text" name="password" size="20" maxlength="20" /></p> <p><input type="submit" name="submit" value="Login" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form> <?php include('./includes/footer.html'); ?> [/code] and the loggedin.php script [code] <?php #logged in page - loggedin.php #user has redirected from login.php //if no cookies are present, redirect the user. if(!isset($_COOKIE['user_id'])) { //start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); //Check for trailing slash if((substr($url, -1) == '/') or (substr($url, -1) == '\\')) { $url = substr($url, 0, -1); //chop off the slash } //add the page. $url .= '/index.php'; header("Location: $url"); exit(); } //Set the page title and include html header. $page_title = 'Logged In!'; include('./includes/header.html'); //Print a customized messages. echo "<h1>Logged In!</h1> <p>You are now logged in, {$_COOKIE['first_name']}!</p><p><br /><br /></p>"; include('./includes/footer.html'); ?> [/code] any ideas?
  13. man your kidding me lmao thanks... so much .... lol probably gonna be more but this one was tough to debug for me...
  14. Hello all ive been folowing a book (PHP and MYSQL for dynamic website by Larry Ullman) and ive created a basic show records page that basically shows the users that are registed to the site. now im on a script that will delete the user from the databse and I got this error: [color=red]Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\wamp\www\PHPScript\delete_users.php on line 70[/color] ive check the coding 4 times and found alot of missing '{' , '}' but i cant seem to find the problem in this one. here the code for delte_users.php: NOTE: line 70 is designated in red. [code]<?php # Delete Users delete_users.php //This page deletes users!!! //This page is accessed through view_users.php $page_title = 'Delete A User'; include('./includes/header.html'); //Check for a valid iser ID, through GET or POST if( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) {//Accessed through view_users.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { $id = $_POST['id']; } else { //no valid id kill the script. echo '<h1 id="mainhead>Page Error!</h1> <p class="error">this page has been accessed in error.</p><p><br /></p>'; include('./includes/footer.html'); exit(); } require_once('./connect/mysql_connect.php'); // Check to see if the form has been submitted. if(isset($_POST['submitted'])) { if($_POST['sure'] == 'Yes') {//delete them //Make the query. $query = "DELETE FROM users WHERE user_id=$id"; $result = @mysql_query ($query); //Run the query. if(mysql_affected_rows() == 1)  {//if it ran ok //print a message echo '<h1 id="mainhead">Delete A User</h1> <p>The user has been deleted.</p><p><br /></p>'; } else { //if it didnt run ok echo '<h1 id="mainhead">System Error!</h1> <p class="error">The user could not be deleted because of a system error.</p>'; //public message echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; //debugging message } } else { // wasnt shure about deleting the user. echo '<h1 id="mainhead">Delete A User</h1> <p>The user HAS NOT been deleted.</p><p><br /><br /></p>'; } } else { //Show the form //Retrieve users information $query = "SELECT CONCAT(last_name, ',', first_name) FROM users WHERE user_id=$id"; $result = @mysql_query ($query); //run the query. if (mysql_num_rows($result) == 1) {//valid user_id show the form. //Get the users information. $row = mysql_fetch_array ($result, MYSQL_NUM); //Create the form. echo '<h2>Delete A User</h2> <form action="delete_users.php" method="post"> <h3>Name: ' . $row[0] . '</h3> <p>Are you sure you want to delete this user?<br /> <input type="radio" name="sure" value="Yes" />Yes <input type="radio" name="sure" value="No" checked="checked" />No</p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id '" /> [color=red]</form>';[/color] } else { //not a valid user. echo '<h1 id="mainhead">Page Error!</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } } //end main submit conditional. mysql_close(); //close connection include('./includes/footer.html'); ?>[/code] any help would be very much appriciated!
  15. Hi, Ijust installed apache 2.0.58 with MySql 5.0.22, PHP 5.1.4 to start learning how to create my own CMS for my website idea. anyways when i try to get to myphpadmin i got "Firefox can't establish a connection to the server at localhost." e.g. http://localhost/phpmyadmin/ or just http://localhost? I did install it before and it worked fine but i forgot my user/pass for myadmin and i uninstalled it and had problems ever since... I also before got an errror saying i couldnt connect ot my DB and needed open port 3306? I wish i would have wrote that dang user/pass down! lol and help will be much appriaciatied! -Matt-
×
×
  • 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.