Jump to content

Blauv

Members
  • Posts

    19
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Blauv's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. TY TY TY, and again TYVM. Worked perfectly, thanks
  2. I want to pull the data listed in this table for this page id,category,view, and datetime are in (forum_category) category_id is found in (forum_question). I would like to show how many topics are listed that relate to the category. (forum_category) category_id is gotten from another page and is the same as the (forum_category) id thus giving the (forum_category) category_id a coresponding (forum_category) id <tr> <td bgcolor="#FFFFFF"><a href="view_category.php?id=<? echo $rows['id']; ?>"><? echo $rows['category']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows1['topic count for each category']; ?></td> <?php?> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr>
  3. i would gladly use another query
  4. no error get thrown, but I can't get the count to show. there are two queries because I am new and the main script was not written by me I am simply adding the catebory to the script. I dont know how to rewrite the original script so I was trying to just add another query to get the numer of topics listed in each category.
  5. ok so what am I doing wrong here??? <?$ sqlTop="SELECT c.id, c.name, COUNT(q.category_id) as total FROM $tbl_name c LEFT JOIN $tbl_name2 q ON c.id = q.category_id GROUP BY c.id"; $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); $result1=mysql_query($sqlTop); ?> <? include("include/session.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>MainForumCategory</title> <meta name="google-site-verification" content="L2Xdw_-D-bNbGZ7Cd-Om03w2oU0f-T7BKwqYNfheaO0" /><meta name="description" content="The Tech Center is a combined resource center for the Novice, and Intermediate Computer User\'s. We offer Computer Repair, and Web Design Software, along with useful link\'s offered in these same catagories to help user\'s solve computer and design problem's quickly and efficiently." /> <meta name="keywords" content="pc repair, computer repair, web design, web developement, HTML, CSS, PHP, MYSQL, computer help, wed design help, computer repair software, web design software, web design link\s, computer repair link\s" /> <meta name="author" content="Blauv" /> <meta name="robots" content="index, follow" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> a:link { text-decoration: none; } a:visited { text-decoration: none; } a:hover { text-decoration: none; color: #F00; } a:active { text-decoration: none; } </style> <link href="TechCenter.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/forum/CreateTopicLight.png')"> <div align="center"> <?php include('header.php'); ?> <br /> </div> <div> <div align="center"><a href="create_category.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Create Topic','','images/forum/CreateCategoryLight.png',1)"><img src="images/forum/CreateCategoryDark.png" alt="Create Topic Now" name="Create Topic" width="116" height="20" border="0" id="Create Topic" /></a> </div> </div> <div align="center"><br /> </div> <table width="75%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="55%" align="center" bgcolor="#E6E6E6"><strong>Category</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6">Topics</td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php // Start looping table row while($rows=mysql_fetch_array($result)){ $rows1=mysql_fetch_array($result1) ?> <tr> <td bgcolor="#FFFFFF"><a href="view_category.php?id=<? echo $rows['id']; ?>"><? echo $rows['category']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows1['c.id']; ?></td> <?php?> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> </table> <?php include('footer.php'); ?> </body> </html>
  6. Hello all. I can't figure out how to perform a compare on two table seperate tables and then disply counted result for specific id to coresponding id from another table. I have two tables 1. forum_category id category name datetime view 2. forum_question category_id topic name datetime view reply forum_question.category_id is gotten from the forum_category.id. I would like to count the topics (forum_question.category_id) that corespondes to each category (forum_category.id) Then disply them beside the category view on my page. The rest of the sql works fine but I have tried and tried many different ways to perform this operation, but sadly I am just to in-experienced to get it right. Here is the current code working exept the category count. Any and all help is much appreciated. <? $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <table width="75%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="55%" align="center" bgcolor="#E6E6E6"><strong>Category</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6">Topics</td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php // Start looping table row while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><a href="view_category.php?id=<? echo $rows['id']; ?>"><? echo $rows['category']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $TopicCount['CANT GET THIS RIGHT']; ?></td> <?php ?> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> </table>
  7. Thanx for the help it finally dawned on me how to get it to work. I had to change the session settings. to the appropriate one for the login session.
  8. I guess I forgot the link but i was way off anyway.
  9. if you are trying to use an image as a submit button have a look at this it fixed it for me.
  10. This was posted by the creator of the login script I would say there is no need to reinvent the wheel so to speak when all the functions you need are already in the code. So for example, the confirmUserpass function in database.php already does this starting line 75. But ultimately I would say it is because you are not using the salt which is added to the password. The salt is saved in the database for each username. What it does is the query gets the password then takes that password and sha1's it with the salt also from the database then matches that with the form submitted password (which must also be salted). A bit complicated I know. function confirmUserPass($username, $password){ /* Add slashes if necessary (for query) */ if(!get_magic_quotes_gpc()) { $username = addslashes($username); } /* Verify that user is in database */ $sql = $this->connection->query("SELECT password, userlevel, usersalt FROM ".TBL_USERS." WHERE username = '$username'"); $count = $sql->rowCount(); if(!$sql || $count < 1){ return 1; //Indicates username failure } /* Retrieve password and userlevel from result, strip slashes */ $dbarray = $sql->fetch(); // $dbarray['password'] = stripslashes($dbarray['password']); $dbarray['userlevel'] = stripslashes($dbarray['userlevel']); $dbarray['usersalt'] = stripslashes($dbarray['usersalt']); $password = stripslashes($password); $sqlpass = sha1($dbarray['usersalt'].$password); /* Validate that password matches and check if userlevel is equal to 1 */ if(($dbarray['password'] == $sqlpass)&&($dbarray['userlevel'] == 1)){ return 3; //Indicates account has not been activated } /* Validate that password matches and check if userlevel is equal to 2 */ if(($dbarray['password'] == $sqlpass)&&($dbarray['userlevel'] == 2)){ return 4; //Indicates admin has not activated account } /* Validate that password is correct */ if($dbarray['password'] == $sqlpass){ return 0; //Success! Username and password confirmed } else{ return 2; //Indicates password failure } }
  11. i tried to switch it to md5 no joy the user table was created for another script and I am trying to convert this to use the existing user table. The user table places the password into the DB as an md5 this script call it from the db as sha1. two seperate scripts.
  12. ok then can you add it?
  13. Uh-oh.. a couple of fields are not filled in correctly.. The username field must not be empty won't show login
  14. I am having some trouble getting this to pull the password correctly from the database. I believe the problem is from the password being in md5 format. I am not sure how to fix the issue. Much thanks <?php //signin.php include 'connect.php'; include 'header.php'; echo '<h3>Sign in</h3><br />'; //first, check if the user is already signed in. If that is the case, there is no need to display this page if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == true) { echo 'You are already signed in, you can <a href="signout.php">sign out</a> if you want.'; } else { if($_SERVER['REQUEST_METHOD'] != 'POST') { /*the form hasn't been posted yet, display it note that the action="" will cause the form to post to the same page it is on */ echo '<form method="post" action=""> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password"><br /> <input type="submit" value="Sign in" /> </form>'; } else { /* so, the form has been posted, we'll process the data in three steps: 1. Check the data 2. Let the user refill the wrong fields (if necessary) 3. Varify if the data is correct and return the correct response */ $errors = array(); /* declare the array for later use */ if(!isset($_POST['username'])) { $errors[] = 'The username field must not be empty.'; } if(!isset($_POST['password'])) { $errors[] = 'The password field must not be empty.'; } if(!empty($errors)) /*check for an empty array, if there are errors, they're in this array (note the ! operator)*/ { echo 'Uh-oh.. a couple of fields are not filled in correctly..<br /><br />'; echo '<ul>'; foreach($errors as $key => $value) /* walk through the array so all the errors get displayed */ { echo '<li>' . $value . '</li>'; /* this generates a nice error list */ } echo '</ul>'; } else { //the form has been posted without errors, so save it //notice the use of mysql_real_escape_string, keep everything safe! //also notice the sha1 function which hashes the password $sql = "SELECT userid, username, userlevel FROM users WHERE username = '" . mysql_real_escape_string($_POST['username']) . "' AND password = '" . sha1($_POST['password']) . "'"; $result = mysql_query($sql); if(!$result) { //something went wrong, display the error echo 'Something went wrong while signing in. Please try again later.'; //echo mysql_error(); //debugging purposes, uncomment when needed } else { //the query was successfully executed, there are 2 possibilities //1. the query returned data, the user can be signed in //2. the query returned an empty result set, the credentials were wrong if(mysql_num_rows($result) == 0) { echo 'You have supplied a wrong user/password combination. Please try again.'; } else { //set the $_SESSION['signed_in'] variable to TRUE $_SESSION['signed_in'] = true; //we also put the user_id and user_name values in the $_SESSION, so we can use it at various pages while($row = mysql_fetch_assoc($result)) { $_SESSION['userid'] = $row['userid']; $_SESSION['username'] = $row['username']; $_SESSION['userlevel'] = $row['userlevel']; } echo 'Welcome, ' . $_SESSION['username'] . '. <br /><a href="index.php">Proceed to the forum overview</a>.'; } } } } } include 'footer.php'; ?>
  15. Here is my updated script fully functional with the image. TY all for your time. <?php include 'connection.php'; if(!isset($_POST['submit'])) { $query = "SELECT * FROM news WHERE id =" . (int)$_GET["id"]; $result = mysql_query($query); $news = mysql_fetch_array($result); $title = $_POST['title']; $body = $_POST['body']; } ?> <html> <head> <link href="../NSNA.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="100%" border="1"> <form action="<?=$_SERVER['SCRIPT_NAME'];?>" method="post"> <tr> <td align="center" colspan="2"><h1>Edit Article</h1></td> </tr> <tr> <td>Title:</td> <td><input type="text" name="title" value="<?php echo htmlentities($news['title']);?>" /></td> </tr> <tr> <td>Article:</td> <td><textarea cols="35" rows="6" name="body"><? echo htmlentities($news['body']);?></textarea></td> </tr> <tr> <td><input type="hidden" name="id" value="<? echo (int)$_GET['id'];?>" /> <input type="image" name="submit" src="../images/admin/editstory.png" /></td> <td><a href="admin.php"><img src="../images/admin/cancel.png" /></a></td> </tr> <tr> <td> </td> <td>Cancel</td> </tr> </form> </table> </body> <?php if (isset($_POST['submit']) || isset($_POST['submit_x']) || isset($_POST['submit_y'])) { $title = mysql_real_escape_string($_POST[title]); $body = mysql_real_escape_string($_POST[body]); $id = mysql_real_escape_string($_POST[id]); $update = "UPDATE news SET `title`='{$title}',`body`='{$body}' WHERE id='{$id}'" or die(mysql_error()); mysql_query($update) or die(mysql_error()); header('Location: /News/admin.php'); die(); } ?>
×
×
  • 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.