Jump to content


  • Posts

  • Joined

  • Last visited


Everything posted by Cell0518

  1. Hi, I was wondering if anyone knew of any tutorials about or of a premade News CMS that uses a MySQL database? I am looking to use one in my site.  *I'm hoping I put this in the correct forum.. *  ??? Thanks, Chris
  2. Thank you for the information, especially showing the $msg = $db->query... line.  This explains something I've wondered about for a while. As far as my site, it would eventually be a news system (with image uploads and a WYSIWIG editor).  I'm looking at a modular design, similar to most forums, ie: example.com/?mod=news&act=update.  How are you able to make a single php file that references all of the data passed by $_GET?  My current page does most of this, but I'm looking to clean the code up....as a lot of the html is sprinkled in and part is just simply echoed. I'm looking at making each part of the news "CMS" modular, as you can see in the example URL, which is, as I said, similar to most news pages I've seen.. (ie * http://www.theinquirer.net/default.aspx?article=34724 * -> when default.aspx sees ?article=, it knows it is an article and it needs to lookup something in (a database?) that has the id of 34724, which is anything after ?article=.) I know that this specific forum uses semi-colons vs ampersands, but how is it all linked?  What code is helping tell that when action=post, you need to get all of the required data, and give the end-user a text box to write in and when they "submit", it goes into a database? Also, if anyone has seen any tutorials, etc that may help answer this question, please post them.  Again, I know I am asking a lot, but I feel that the best way for me to learn my php is by making something. Thanks, Chris
  3. What package did you install?  This would give us a way to see ALL of the code. Thanks, Chris
  4. Hi, this was an example, simplified to not take up too much room. :)  How does the <<<EOF .... EOF; work? (I'm taking it that anything within {} is parsed, everything else is not?) In the possiblity of using a switch, I assume the way to implement the pieces of code more effectively would be to include them from separate the files? My site would eventually be a news system (with image uploads and a WYSIWIG editor).  If you know of any tutorials that would help, I would be greatly appreciated. Thanks, Chris
  5. what is the difference? ( if ($act == "") and  if ("" == $act) ) Also, I don't want to sound stupid, but what is K&R and Allman? ( I updated the original post :) ) Thanks, Chris
  6. Hi, I have a question.  When coding a update form, I want the data to be pulled from a MySQL DB. In trying to code better and I'm looking to have a better layout for my code, so it seems less cluttered and more stuctured and possibly using a template. My current code is similar to this... [code] <?php $act = $_GET['act']; if($act == "") { $query = "GET title FROM table1"; $db->query($query) while($row = mysqli_fetch_array($result, MYSQL_ASSOC)) { echo "<html>\n<head>....Update Data"; echo "<input type=\"text\" value=\"".$row['title']."\">"; echo "<input type=\"submit\" calue=\"\">"; } } if($act == "update") { $query = "....."; if($db->query($query)) { $msg = "Successful" } else { $msg = "Unsuccessful" } echo "<html>\n<head>....Data Results.."; echo $msg; echo "</body></html>"; } ?> [/code] Is there a better way to code something like this? (as in, separating the HTML from the results...) Thanks, Chris
  7. Hi, I am looking to better organize my site's code and I'm looking at templating. I've run into a few questions: looking at my current layout (below) [b]Home Page[/b] [img]http://ftp.chrisloveonline.com/dslr-1.jpg[/img] A lot of my data is being pulled from the same database, using several MySQL queries.  Tables are being used in a lot of the overall page layout with 3 separate tables (one each for header, overall content and footer), with the center table having 3 columns (blue borders showing each). All 3 tables are consistent with the entire site (other than forum / gallery).  Most of the pages are only using the center column, with the home page being the exception.  I'm looking for a good way to clean up my code, as a lot of the html formatting for the results of the queries is just echoed. [code]for($total_number,$number,$number++) { echo "<b>".$query1_array['title']."</b>"; }[/code] I feel I must be over complicating this, as it seems like a very large task. Can someone point me in the right direction on a tutorial / example that would help me? Thanks for you time, Chris
  8. Hi, thanks for the article on the templating.  I've already read some of it and it looks very informative and very useful. Now, I'm trying to figure out how to use this in a modular aspect, as in a url that is www.example.com/admin/index.php?module=news&action=add. (this is basically how my site works now, although it's currently kinda messy as mentioned in my first post) What is interpreting the url and decifering what code needs to be pulled and processed and what is shown?  I understand that $_GET["module"] would be equal to the value in the url.  Is someone going to say [code] if ($module = "news") { code } elseif ($module = "settings") { more code } else { generic error code / menu } [/code] or is there a better way? Thanks, Chris
  9. How many of you, in coding your own CMS worked to make the PHP separate from HTML?  Does anyone have any good resources that helped them with this? I am running a news site that deals with Photography news, specifically for Digital Single Lens Reflex (D-SLR) cameras.  I am having a hard time implementing this, as I feel the html / css formatting is hard to strip from the functional PHP. For example, when designing the posting of the news, the news is (for the moment) in a generic text box.  I am coding the formatting when I write the article (including links, images, etc).  (I am wanting to eventually move to a WYSIWYG editor, like many forums use, but have yet to find a good article that shows a good cross browser method and I haven't looked into any of the pre-made ones yet, as mentioned in an earlier reply.) My current CMS code works like such... [code] <?PHP Session check (see if the user is logged in) include the "user_config" file Basic starting html (such as <html> and <head>) if ($act = "add") { if (isset($_POST["content"])) { mysql query to insert into DB if($db->query("INSERT....")  {$post_msg = "Good"} else {$post_msg = "Bad"} } if (isset($post_msg)) { code to display msg } HTML Form continuing to have an elseif for edit and a "catch all" else "clean up" display if neither is set. ?> [/code] In addition, I am expanding what I want to do with the site and I'm working to try to make the site modular. I'm beginning to see why people say the code should be separate from the design, as I feel the current code is "messy" and needs a restructuring. Your help would be greatly appreciated. Thanks, Chris
  10. Register Globals is off. 1.  you need to place $varname = $_GET["varname"] for php to look for the variable passed in the url. *( place the code before the variable is used )* Example: $product = $_GET["product"]; echo $product; 2.  Check this line -> [code]<td width="520" rowspan="3" bgcolor="#E7E7DD" valign="top"><iframe id="productmain" src="<?=$url;?>".....[/code] replace <?=$url;?> with either <? echo $url; ?> or <? print $url; ?>
  11. I know this is an odd question, but after reading some code (Gallery 2), I see: [code]GalleryCoreApi::requireOnce([/code] What does the :: between the GalleryCoreApi mean?  The Core Api is a class and I understand requireOnce, but usually it's require_once(.... is :: the same as -> ? Thanks, CL.
  12. Fixed, Thanks.  I didn't realize you needed both GET and =. Thanks.
  13. I am passing a variable through the url ($_get) example: http://www.dslr-photography.com/chk_id.php?id=3 [code] <?php //Setup $id echo "ID CHECKER<br />"; $id == $_get['id']; echo "Story ID = ".$id; ?> [/code] Why is this not working?  I am very frustrated with this simple, stupid problem.  ??? >:( :-[ I've tried $_GET, $_get, 'id', "id".
  14. Does the variable need to be: $_GET["p"] = $p; or $p = $_GET["p"]; or do both the same? Does the variable (in PHP5) usually continue to an included file?
  15. Hi, I'm trying to pass a variable to an included file, that would choose the page.  the variables are pre-set to make the header, menu and include a php file.  This file is included within the index.php file. I've tried placing $_GET["p"]= $p; in both init.php and index. (I even have the variable echoing with a string and It is not showing a value.)  Your help would be appreciated. Thanks, Chris index.php - basically is a wrapper (Like IPB, for example) [code]<?php //Index PHP File //Written by Chris Love //Revision Date: 08/03/06 //include conf and init require_once './conf_global.php'; require_once './init.php'; //define vars $_GET["p"] = $p; ?> [/code] init.php (initializes basic variables and page selection) [code]<?php //Init PHP File //Written by Chris Love //Revision Date: 08/03/06 //APP Configs //Added 08/03/06 define( 'ROOT_PATH', dirname( __FILE__ ) ."/" ); //IN DSLR //Added 08/03/06 define ( 'IN_DSLR', 1 ); //DSLR INIT DONE //Added 08/03/06 define ( 'DSLR_INIT_DONE', 1 ); //include layout and classes require_once ROOT_PATH . 'sources/layout/layout.php'; require_once ROOT_PATH . 'sources/classes/class.list.php'; //check if site closed //Last Mod 08/03/06 echo "the var p = ".$p; if($pageMaintenance != '0') $p = "maint"; else { $p = "idx"; } if( $p == "idx" ) {        dslrHeader("DSLR-Photography : Digital SLRs, Photography and Imaging");     dslrMenu();     include ROOT_PATH . 'sources/include/main.php'; } elseif ( $p == "news" ) {     dslrHeader("DSLR-Photography : News");     dslrMenu();     include ROOT_PATH . 'sources/include/news.php'; } elseif ( $p == "links" ) {     dslrHeader("DSLR-Photography : Links");     dslrMenu();     include ROOT_PATH . 'sources/include/links.php'; } elseif ( $p == "about" ) {     dslrHeader("DSLR-Photography : About Us");     dslrMenu();     include ROOT_PATH . 'sources/include/about.php'; } elseif ( $p == "maint" ) {     dslrHeader("DSLR-Photography.com : Site Maintenance");     include ROOT_PATH . 'sources/include/maint.php'; } else {     dslrHeader("DSLR-Photography : Error");     dslrMenu();     include ROOT_PATH . 'sources/include/error.php'; } footer(); ?> [/code]
  16. Thanks for your help. I got that last bit sorted out, and it runs great. Thanks again! :D :SOLVED: oops, I meant your, not you.... :O
  17. well, I added a var $updated-contents; in the class (i'm continuing to update the file in the 1st post) I also have it returning the postMessage. It is returning a bad, I can't update the file message, but It's still saving as a blank file. Thanks for you help, Chris
  18. It reads just fine now, thanks. Now, I need to figure out how to fix the "write" function. It's writing back a blank file.
  19. I've updated the files to include the updates, but still no go. Anything else you see? Thanks again, Chris
  20. I've updated the file to include a setFilename() function. Thanks again, Chris
  21. Hi, I'm setting up a class to read and write to a file. The code I've posted is trimmed to only include the needed code (both the classes and config files are "included" in a broad "main" file) *Moved code due to Safety script "403"ing... [a href=\"http://ftp.chrisloveonline.com/config.phps\" target=\"_blank\"]http://ftp.chrisloveonline.com/config.phps[/a] At this point, when I have it read, it gets nothing. Help would be appreciated, Chris
  22. Wildteen88, It worked, thanks for you help. :) CL
  23. I'm piecing together a login utility that checks a MySQL database, and if you are found, it will set 2 session vars (a 3rd for user type, aka admin / regular, etc is commented). At this point, it keeps exiting the loop, not setting a session and never redirecting. The User not validated message keeps showing. I can't seem to figure out what I'm doing wrong. I've used a similar function before, but I can't figure what's wrong. Please help. [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] Thanks, Chris [code] <!--HEADER GOES HERE--> <?php session_start(); if( $action=="login" && isset($_POST['username'])) {     $username = $_POST['username'];     $password = $_POST['password'];     // MySQL Connection     require "config.php";     $conn = mysql_connect("$dblocation","$dbusername","$dbpassword");        if (!$conn) die ("Could not connect MySQL"); {        mysql_select_db($dbname,$conn) or die ("Could not open database");        $query = "SELECT user_name, user_group FROM `db1` WHERE user_name = '$username' AND user_password = PASSWORD('$password')";       $result = mysql_query($query);     if (mysql_num_rows($result) == 1) {     // the user name and password match,     $_SESSION['user'] = $username;     $_SESSION['loggedIn'] = true;     /*while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {     $userGroup = $row['user_group'];     echo $userGroup;     session_register("userGroup"); //is this really needed?     $_SESSION['userGroup'] = $userGroup;         }*/     header("Location: ".$url);     }     }     // nothing became valid while we looped so verification failed     echo "<b>Incorrect Username or Password</b><p />"; } elseif($action=="logout") {     session_start();     session_unset();     session_destroy();     echo '<b>You have successfully logged out!</b><p />'; } else {} ?> <form action="admin.php?action=login" method="post">     <p>Username: <input type="text" name="username"><br>     <p>Password : <input type="password" name="password"><br>     <input type="submit" value=" Login "> </form> <!-- REST OF FOOTER--> [/code]
  24. [!--quoteo(post=375652:date=May 21 2006, 01:07 PM:name=jeremywesselman)--][div class=\'quotetop\']QUOTE(jeremywesselman @ May 21 2006, 01:07 PM) [snapback]375652[/snapback][/div][div class=\'quotemain\'][!--quotec--] There is an easier way to do this without classes. You can use a switch statement which makes it a whole lot easier. [code]<?php //use a switch statement to find out which page is in the URL switch($_GET['p']) {      case 'about':      {       //this is where you include the file you want to display.       include('about.inc');      }      break;          default:      {           include('main.inc');      }      break; } ?>[/code] This should make it a lot easier. [!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] [/quote] Question is though, I would have to make a new case for every page I have, albeit it's not that many, I was looking for it being a little more dynamic, in the case I added more pages in the future.
  • 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.