LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-29-2006, 06:30 PM   #1
karan101
Member
 
Registered: Aug 2004
Location: CANADA
Distribution: Fedora core4
Posts: 60

Rep: Reputation: 15
Html/php


Hello everyone
for the past month Ive been studying php. what a beautifull language. Now I have a question I don't know if I can do this with php or its better doin it with some other language.

My Question:

I have a news section on my website, I'd like to make it dynamic so the content will be read from a seperate file say news.txt so I just have to update my news.txt file.
I don't know if macromedia dreamweaver/MS front page, has that option or not

It would be appreciated if someone can help me with this or just direct me to a link that has some help on this..

regards
Karan
 
Old 07-29-2006, 06:35 PM   #2
tangle
Senior Member
 
Registered: Apr 2002
Location: Arbovale, WV
Distribution: Slackware
Posts: 1,761

Rep: Reputation: 78
Here is a link that tells you how to do it in php.
http://www.faqts.com/knowledge_base/...d/20039/fid/51

I think php is the right choice. Of cource I find javascript cryptic.
 
Old 07-30-2006, 08:23 PM   #3
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
The format of the text file matters, a bit. The link the previous poster gave you will get you going, but you might want to parse the incoming file to add html tags such as <p> or whatever.

If you use readfile and need to format, you will have to buffer your output then process the output buffer. It might be easier to use fopen and fread to bring the input file in a line at a time and place it in a string variable, then parse and edit it, then ship it to the output buffer.

There are also security issues with readfile; if you aren't careful then someone "out there" someplace can exploit your script to read unexecuted php files, thereby gaining all the information needed to exploit any vulnerabilities that might exist.
Your call; there are any number of ways to do just about anything in PHP.

Last edited by jiml8; 07-30-2006 at 08:26 PM.
 
Old 07-30-2006, 09:03 PM   #4
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
In my web development days, I never really got into PHP much. I kept everything to Perl/CGI and HTML.

I essentially did what you are trying to do with everything on my old site: my menu bars on the page were one file, the content body of the page was another file, and so on.

What I see as a joy of Perl/CGI is that it's quite secure (I've heard of there being some "exploitation" risks with PHP), and you don't have to worry about how you structure the content in your *.txt file, you just have to structure the Perl code to handle the content it's reading, and then structure your text file according to how you want it to be read - If you would like an example of this, just let me know =).
 
Old 07-30-2006, 09:53 PM   #5
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
have you considered installing a database such as mysql? the effort required to get it going would be comparable to the file based approach, and it would scale a whole lot better..
 
Old 07-31-2006, 09:18 AM   #6
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Perl can be exploited too. You just have to write your perl code to prevent that, just as you have to write your php code to prevent that.

Max nix.
 
Old 07-31-2006, 04:16 PM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
edit : nothing to say, all was on the link above :$

Last edited by keefaz; 07-31-2006 at 04:17 PM.
 
Old 07-31-2006, 08:19 PM   #8
karan101
Member
 
Registered: Aug 2004
Location: CANADA
Distribution: Fedora core4
Posts: 60

Original Poster
Rep: Reputation: 15
thnx everyone

well I tought of puting it in mysql and just read it from there... but wouldn't be easier to just read it from a .txt or .xml file... security is not an isssue since my mom is going to update the file on daily bases. therefore from my undrestanding so far one way of doing this is just put contents in a file with whatever html tags and read it line by line with php and parse it into my table/section of my webpage.
thanks everyone
 
Old 08-01-2006, 06:48 PM   #9
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
I had understood that your mother was going to update this file. Does she speak html?

Putting any needed html tags into the text file is certainly an easy thing to do, but only if the person putting the tags in knows html. Alternatively, it isn't hard to parse a text file to determine which html tags are needed.
 
Old 08-02-2006, 07:57 AM   #10
karan101
Member
 
Registered: Aug 2004
Location: CANADA
Distribution: Fedora core4
Posts: 60

Original Poster
Rep: Reputation: 15
triggering php with hyperlinks

Hello everyone

here is my questions: I have a table with 2 columns. In first column I have 2 links which by clicking on each link I'd like a different .txt file parses into the second column. I'm not sure how exactly I can trigger a php with hyper links and how I can print the file into the the 2nd column. I know as much as how to trigger it with submit button. any help would be appreciated

Last edited by karan101; 08-02-2006 at 07:58 AM.
 
Old 08-03-2006, 02:42 AM   #11
smallville
Member
 
Registered: Dec 2005
Posts: 44

Rep: Reputation: 15
<a href="file1.php" target="left" onClick="left.content.location='file1.php'">
My File</a>

Note: The target="left" pertains to the name of the 2nd column/frame
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
html into php charnel Programming 7 08-30-2005 10:47 AM
PHP/html forum FedoraUsr Programming 2 08-18-2005 01:07 PM
php in html code blizunt7 Programming 5 06-15-2005 01:08 PM
html to php? help me please!!!!! trscookie Programming 4 01-24-2005 06:36 AM
.htaccess .html -> .php timmy01 Linux - General 2 09-07-2003 05:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration