Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 30th, 2003, 06:07 PM
neliconcept neliconcept is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 neliconcept User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to neliconcept
tutorial question on news script part 1

hello im trying to embedd this script into a page im working on and im wondering if its possible to add another part on the form such as title for the title of the news box as im trying do do here

URL

its hard for me to explain but i added another

php Code:
Original - php Code
  1. if(!$HTTP_POST_VARS['title']) {
  2.             echo "You must enter a title";
  3.             exit;
  4.         }         


and for the other part too

but it is not working rightly and i was wondering if anyone could help me

ill show you all of the code

addnews.php code
php Code:
Original - php Code
  1.  
  2. <?
  3. if($HTTP_POST_VARS['submit']) {
  4.     if($HTTP_POST_VARS['password'] == 'test') {
  5.     if(!$HTTP_POST_VARS['title']) {
  6.             echo "You must enter a title";
  7.             exit;
  8.         }       
  9.     if(!$HTTP_POST_VARS['name']) {
  10.             echo "You must enter a name";
  11.             exit;
  12.         }
  13.         if(!$HTTP_POST_VARS['news']) {
  14.             echo "You must enter some news";
  15.             exit;
  16.         }
  17.     if(strstr($HTTP_POST_VARS['title'],"|")) {
  18.             echo "Name cannot contain the pipe symbol - |";
  19.             exit;
  20.     }
  21.         if(strstr($HTTP_POST_VARS['name'],"|")) {
  22.             echo "Name cannot contain the pipe symbol - |";
  23.             exit;
  24.         }
  25.         if(strstr($HTTP_POST_VARS['news'],"|")) {
  26.             echo "News cannot contain the pipe symbol - |";
  27.             exit;
  28.         }
  29.         $fp = fopen('news.txt','a');
  30.         if(!$fp) {
  31.             echo "Error opening file!";
  32.             exit;
  33.         }
  34.         $line = date("m.d.y") . "|" . $HTTP_POST_VARS['name'];
  35.         $line .= "|" . $HTTP_POST_VARS['news'];
  36.         $line = str_replace("rn","<BR>",$line);
  37.         $line .= "rn";
  38.         fwrite($fp, $line);
  39.         if(!fclose($fp)) {
  40.             echo "Error closing file!";
  41.             exit;
  42.         }       
  43.     } else {
  44.         echo "Password is incorrect, Please try again!";
  45.     }
  46. }
  47.  
  48. ?>
  49. <FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry">
  50. Title:<BR>
  51. <INPUT TYPE="text" SIZE="30" NAME="title"><BR>
  52. Your name:<BR>
  53. <INPUT TYPE="text" SIZE="30" NAME="name"><BR>
  54. The News:<BR>
  55. <TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR><BR>
  56. News Password:<BR>
  57. <INPUT TYPE="password" SIZE="30" NAME="password"><BR>
  58. <INPUT TYPE="submit" NAME="submit" VALUE="Post it!"><BR>
  59. </FORM> 


here is my news box code
php Code:
Original - php Code
  1.  
  2. <td background="newstitlebar.gif" width="434" height="28"><table width="434" cellpadding="2"><tr><td width="6%"></td><td>
  3. <?PHP
  4. $data = file('news.txt');
  5. $data = array_reverse($data);
  6. foreach($data as $element) {
  7.     $element = trim($element);
  8.     $pieces = explode("|", $element);
  9.     echo $pieces[0];
  10. }
  11. ?>
  12. </td></tr></table></td>
  13. </tr>
  14. <tr>
  15. <td background="newspersonbar.gif" width="434" height="21" valign="top"></td>
  16. </tr>
  17. <tr>
  18. <td background="newspost.gif" width="434"><table width="434" cellpadding="2"><tr><td>
  19. <?PHP
  20. $data = file('news.txt');
  21. $data = array_reverse($data);
  22. foreach($data as $element) {
  23.     $element = trim($element);
  24.     $pieces = explode("|", $element);
  25.     echo $pieces[3] . "<BR>" . "<b>Posted by " . $pieces[2] . " on " . $pieces[1] . "</b><BR><BR>";
  26. }
  27. ?>
  28. </td></tr></table></td>
  29. </tr>
  30. <tr>
  31. <td background="newsbot.gif" width="434" height="2"></td>
  32. </tr>
  33. </table>


if anyone could help me i would be grateful

Reply With Quote
  #2  
Old May 31st, 2003, 03:31 AM
neliconcept neliconcept is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 neliconcept User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to neliconcept
RE: tutorial question on news script part 1

seems like it writes to the news.php file now thank god

but still having trouble figuring out how to transfer it to the tables on the page

anyone out there that can help around here would be appreciated

thanks

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > tutorial question on news script part 1


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek