DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   need help finding a script or tool to use for a news update program. (http://www.daniweb.com/forums/thread20550.html)

jilly Mar 20th, 2005 3:39 am
need help finding a script or tool to use for a news update program.
 
I made a basic website for my sons' garage band, and they want on the front page to have a box that the four of them can update with the 'latest news' - so I want it to be something they's have to log in to use, or at least enter a password to get into, and then have the 'news' they post show up on the front page of their site. Right now the page is an index.html page. I am thinking that PhP can probably do this pretty easily, but I dont know where to find a script about it, or how to configure it so that it will show the latest news articles on the home page.. Any directions or ideas?

paradox814 Mar 20th, 2005 4:27 am
Re: need help finding a script or tool to use for a news update program.
 
do you have access to a database? if so then i wouldn't bother with loggin in, as that would be too much work for the sole purpose of adding latest news.
Create a new php page with a form use that has everything you want, and then just put a password field as one of the inputs, if the password isn't correct then don't update. if the password is correct then add it to the database.

PoA Mar 20th, 2005 11:21 pm
Re: need help finding a script or tool to use for a news update program.
 
CuteNews
http://cutephp.com/cutenews/

FusionNews
http://www.fusionphp.net/index.php?c...&page=features

Hope it helps

jilly Mar 21st, 2005 10:24 am
Re: need help finding a script or tool to use for a news update program.
 
woohoo, thanks!

Paradox, what you have posted is a bit beyond my current ability without some handholding - I will probably try the links in the next post, if not I may come back and ask you to hold my hand while walking through the php page!!

barnamos Mar 22nd, 2005 7:32 pm
Re: need help finding a script or tool to use for a news update program.
 
Database is really made for this but if you have no db, you can get pretty creative and use fopen & fwrite to write a text file to your server. The password dealy mentioned above would help as a simple authentication, nothing happens if password isn't right. So if you have a form input named mytext...

$file_name = fopen("/path/to/homedir/myfile.txt","w+");
$file = $HTTP_POST_VARS["mytext"];
fwrite($file_name,$file);
fclose($file_name);

Then your page could include the text file.
<? include 'myfile.txt'; ?>

You might make a blank file on the server to get started. Also make sure apache can write to it!!!

Good luck

jilly Mar 23rd, 2005 3:42 pm
Re: need help finding a script or tool to use for a news update program.
 
I have access to mysql databases, so I could do that, but the problem is that the only database and php I know so far came from admin'ing my vbulletins and hacking them.. LOL - I don't really know how to do one from scratch. Also the main home page is an index.html file, and I need to turn it into an index.php file I think - and I am not sure how to do that... D'oh! Any more advice??

barnamos Mar 23rd, 2005 4:25 pm
Re: need help finding a script or tool to use for a news update program.
 
Quote:

Originally Posted by jilly
I have access to mysql databases, so I could do that, but the problem is that the only database and php I know so far came from admin'ing my vbulletins and hacking them.. LOL - I don't really know how to do one from scratch. Also the main home page is an index.html file, and I need to turn it into an index.php file I think - and I am not sure how to do that... D'oh! Any more advice??

Aha, you're in good shape then. You can just rename your page index.php and you won't know any difference until you start to add some actual php tags.

you'll need to do 2 things...

1) Put data in

As far as getting the data in, you'll need make a database table to store this data. Hopefully you have access to phpMyAdmin or a Webmin/UserMin access to MySQL. Get there, and make a table. Something simple, say name it content and have one field called text and use another as the id. You probably can do that through whatever web interface or find a place to give a SQL command of:

CREATE TABLE `content` (
`id` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`text` TEXT NOT NULL ,
PRIMARY KEY ( `id` )
);

Then make a new php page on your site, say called input.php. This page will have the form and also the action part of inputting the text.

input.php would look something like this.
<?
if ($submit && ($password == "kidspassword)) {
// let me talk to the database using my mysql username and mysql password
$myconnect = mysql_connect("localhost","username","password");
mysql_select_db("databasename",$myconnect); // not tablename but db name

mysql_query("REPLACE INTO content ('id','text') VALUES ('1','$text')
or die(mysql_error());

echo "Did it!";?>
<html><body>
<form>
Input the text for the page:
<textarea name="text" cols="20" rows="5"></textarea>
Password: <INPUT type="password" name="password">
<INPUT type="submit" name="submit"></form>
</body></html>

You can add additional areas by duplicating and changing the 1 to a 2 or whatever.

2) Get data out

On index.php..

<? // again let me talk to the database
$myconnect = mysql_connect("localhost","username","password");
mysql_select_db("databasename",$myconnect); // not tablename but db name
?><html><body>

etc etc
<? // Pull text out and make purty
$my_text = mysql_result(mysql_query("SELECT text FROM content
WHERE id = '1' "),0);
echo nl2br(stripslashes($my_text));
?>
etc </body></html>

The nl2br will put <br/> tags in on each line break and the stripslashes will take out any \' or \" that find their way in.

Untested and untried but worth every penny you paid for it!









:D

jilly Mar 25th, 2005 4:21 pm
Re: need help finding a script or tool to use for a news update program.
 
Thanks barnamos - I am going to try this this weekend and see if I can get it to work!!

kiwisites Jan 17th, 2008 3:52 pm
Re: need help finding a script or tool to use for a news update program.
 
Oh My my.. why use PHP, Database and do so much truble...

HOw about getting it using Javascript AJAX script.. with a simple TEXT FILE...
yes...

Check this site http://www.inspiringourchildren.info/

And the source code is available at
http://www.dynamicdrive.com/dynamici...ajaxticker.htm

Regards
Kiwi

nav33n Jan 17th, 2008 8:03 pm
Re: need help finding a script or tool to use for a news update program.
 
You bumped into a 2.5 yr old thread :) !


All times are GMT -4. The time now is 7:13 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC