| | |
need help finding a script or tool to use for a news update program.
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2005
Posts: 6
Reputation:
Solved Threads: 0
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?
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.
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.
•
•
Join Date: Jul 2004
Posts: 234
Reputation:
Solved Threads: 8
CuteNews
http://cutephp.com/cutenews/
FusionNews
http://www.fusionphp.net/index.php?c...&page=features
Hope it helps
http://cutephp.com/cutenews/
FusionNews
http://www.fusionphp.net/index.php?c...&page=features
Hope it helps
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
$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
•
•
Join Date: Mar 2005
Posts: 6
Reputation:
Solved Threads: 0
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??
•
•
•
•
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??
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!
•
•
Join Date: Oct 2007
Posts: 13
Reputation:
Solved Threads: 0
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
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
![]() |
Other Threads in the PHP Forum
- Previous Thread: Inserting an uploaded file name into a database
- Next Thread: Community Solutions like communityserver.com
| Thread Tools | Search this Thread |
.htaccess alexa apache api array beginner beneath binary broadband broken cakephp checkbox class cms code convert cron curl database date display dynamic echo email encode error explodefunction fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert ip javascript joomla key keywords limit link login mail mail() memberships menu mlm multiple multipletables mysql mysql_real_escape_string network oop open passwords paypal pdf php provider query radio random redirect remote rss script search securephp server sessions smtp source space sql strip_tags syntax system table template tutorial update upload url user validator variable video voteup web youtube







!