943,546 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 8820
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 10th, 2007
0

New CMS - Help Needed

Expand Post »
Ok i am making a CMS using PHP/Mysql (its designed as a learning experience for me so it will not be anything like mambo etc... )

Anyway, here are some screenies. If anyone wants to help then I would happily share what little code I have written.
Attached Thumbnails
Click image for larger version

Name:	add.JPG
Views:	200
Size:	46.0 KB
ID:	3390   Click image for larger version

Name:	id.JPG
Views:	152
Size:	67.4 KB
ID:	3391   Click image for larger version

Name:	main.JPG
Views:	151
Size:	41.4 KB
ID:	3392  
Last edited by jbennet; May 10th, 2007 at 7:01 pm.
Similar Threads
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
May 10th, 2007
0

Re: New CMS - Help Needed

Looks like a good start. No better way of learning than diving in and trying to actually build something useful!
pty
Reputation Points: 64
Solved Threads: 39
Posting Pro
pty is offline Offline
530 posts
since Oct 2005
May 11th, 2007
0

Re: New CMS - Help Needed

hmm i am going to try and add a search function and an admin panel
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
May 11th, 2007
0

Re: New CMS - Help Needed

hey heres a little function i used in order to make PHP's date/time more human readable.

PHP Syntax (Toggle Plain Text)
  1.  
  2. <?php
  3. function formatDate($val)
  4. {
  5. $arr = explode('-', $val);
  6. return date('d M Y', mktime(0,0,0, $arr[1], $arr[2], $arr[0]));
  7. }
  8. ?>

someone may find it useful
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
May 11th, 2007
0

Re: New CMS - Help Needed

Aha! Ok i made the admin panel. The admin can now add/edit/delete

now i just need some sort of authentication and a search function
Attached Thumbnails
Click image for larger version

Name:	add.jpg
Views:	53
Size:	41.1 KB
ID:	3393   Click image for larger version

Name:	admin.JPG
Views:	67
Size:	37.0 KB
ID:	3394   Click image for larger version

Name:	edit.jpg
Views:	64
Size:	58.6 KB
ID:	3395   Click image for larger version

Name:	index.JPG
Views:	62
Size:	30.1 KB
ID:	3396   Click image for larger version

Name:	story.JPG
Views:	59
Size:	77.1 KB
ID:	3397  

Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
May 11th, 2007
0

Re: New CMS - Help Needed

why is this code not working:

(its meant to edit - i always get error on the last line?)

PHP Syntax (Toggle Plain Text)
  1.  
  2. <html>
  3. <body>
  4. <table width="100%" cellspacing="0" cellpadding="5">
  5. <tr>
  6. <td bgcolor="Orange"><font size="5" color="Black">
  7. <b>James Bennet's CMS</b></font>
  8. </td>
  9. </tr>
  10. </table>
  11. <?php
  12. include('../lib/conf.php');
  13. include('../lib/functions.php');
  14. if (!$_POST['submit'])
  15. {
  16. if ((!isset($_GET['id']) || trim($_GET['id']) == ''))
  17. {
  18. die('Missing record ID!');
  19. }
  20. $connection = mysql_connect($host, $user, $pass) or die ('Unable to connect to mysql database!');
  21. mysql_select_db($db) or die ('Unable to select mysql database!');
  22. $id = $_GET['id'];
  23. $query = "SELECT title, content, contact FROM news WHERE id = '$id'";
  24. $result = mysql_query($query) or die ("Error in mysql query: $query. " . mysql_error());
  25.  
  26. if (mysql_num_rows($result) > 0)
  27. {
  28. $row = mysql_fetch_object($result);
  29. ?>
  30. <table cellspacing="5" cellpadding="5">
  31. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
  32. <input type="hidden" name="id" value="<?php echo $id; ?>">
  33. <tr>
  34. <td valign="top"><b><font size="2">Title</font></b></td>
  35. <td>
  36. <input size="50" maxlength="250" type="text" name="title"
  37. value="<?php echo $row->title; ?>">
  38. </td>
  39. </tr>
  40. <tr>
  41. <td valign="top"><b><font size="2">Content</font></b></td>
  42. <td>
  43. <textarea name="content" cols="40" rows="10">
  44. <?php echo $row->content; ?>
  45. </textarea>
  46. </td>
  47. </tr>
  48. <tr>
  49. <td valign="top"><b><font size="2">Contact Address:</font></b></td>
  50. <td>
  51. <input size="50" maxlength="250" type="text" name="contact"
  52. value="<?php echo $row->contact; ?>">
  53. </td>
  54. </tr>
  55. <tr>
  56. <td>
  57. <input type="Submit" name="submit" value="Edit">
  58. </td>
  59. </tr>
  60. </form>
  61. </table>
  62. <?php
  63. }
  64. else
  65. {
  66. echo '<font size=-1>That content could not be located in our database.</font>';
  67. }
  68. }
  69. else
  70. {
  71. $errorList = array();
  72.  
  73. $title = $_POST['title'];
  74. $content = $_POST['content'];
  75. $contact = $_POST['contact'];
  76. $id = $_POST['id'];
  77.  
  78. if ((!isset($_POST['id']) || trim($_POST['id']) == ''))
  79. {
  80. die ('Missing record ID!');
  81. }
  82. if (trim($_POST['title']) == '')
  83. {
  84. $errorList[] = 'Invalid entry: Title';
  85. }
  86.  
  87. if (trim($_POST['content']) == '')
  88. {
  89. $errorList[] = "Invalid entry: Content";
  90. }
  91.  
  92. if (trim($_POST['contact']) == '')
  93. {
  94. $contact = $def_contact;
  95. }
  96.  
  97. if (sizeof($errorList) == 0)
  98. {
  99. $connection = mysql_connect($host, $user, $pass) or die ('Unable to connect to mysql database!');
  100. mysql_select_db($db) or die ('Unable to select mysql database!');
  101. $query = "UPDATE news SET title = '$title', content = '$content', contact = '$contact', timestamp = NOW() WHERE id = '$id'";
  102. $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
  103. echo '<font size=-1>Update successful!';
  104. echo '<a href=index.php>Go back to the main menu</a>.</font>';
  105. mysql_close($connection);
  106. }
  107. else
  108. {
  109. echo '<font size=-1>The following errors were encountered:';
  110. echo '<br>';
  111. echo '<ul>';
  112. for ($x=0; $x<sizeof($errorList); $x++)
  113. {
  114. echo "<li>$errorList[$x]";
  115. }
  116. echo '</ul></font>';
  117. }
  118. }
  119. ?>
  120. </body>
  121. </html>
  122.  
Last edited by jbennet; May 11th, 2007 at 12:24 pm.
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
May 11th, 2007
0

Re: New CMS - Help Needed

You probs missed a { or } or ( or ) somewhere
otherwise that is my knowledge wasted!
Reputation Points: 533
Solved Threads: 46
Posting Maven
Serunson is offline Offline
2,576 posts
since Mar 2007
May 11th, 2007
0

Re: New CMS - Help Needed

== '') ==> that dont look right ~
should it not be like =="") ?
Reputation Points: 533
Solved Threads: 46
Posting Maven
Serunson is offline Offline
2,576 posts
since Mar 2007
May 11th, 2007
0

Re: New CMS - Help Needed

here are screenshots of the newest version . I got .htaccess authentication running. Full code is here and if possible can get some help making it look nicer.

Source code included (not the htaccess stuff)
Attached Thumbnails
Click image for larger version

Name:	add.JPG
Views:	54
Size:	41.9 KB
ID:	3401   Click image for larger version

Name:	admin.JPG
Views:	69
Size:	59.5 KB
ID:	3402   Click image for larger version

Name:	article.JPG
Views:	43
Size:	92.8 KB
ID:	3403   Click image for larger version

Name:	cp.JPG
Views:	38
Size:	43.8 KB
ID:	3404   Click image for larger version

Name:	edit.JPG
Views:	41
Size:	59.6 KB
ID:	3405  

Click image for larger version

Name:	main.JPG
Views:	36
Size:	41.5 KB
ID:	3406  
Attached Files
File Type: zip index.zip (5.7 KB, 99 views)
Last edited by jbennet; May 11th, 2007 at 6:14 pm.
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
May 12th, 2007
0

Re: New CMS - Help Needed

Why don't use Smarty?
Reputation Points: 10
Solved Threads: 0
Junior Poster
didier-fr is offline Offline
143 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Session Admin Advice?
Next Thread in PHP Forum Timeline: sql INSERT question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC