#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Randolph, NJ
    Posts
    36
    Rep Power
    15
    Ok. I need advice to make this script. Or help me write it, whatever, I dont mind.


    Ok, I need an article script that has like an Admin Page that several people can log into. Their Login Name is their identity in the Article. Now, there will be fields like Date, Title, and Article. The Article one will be a large text field. Now, when they submit the article it sends the info to a MySQL database, with those fields(including the Name filed from the login). And the article is given an ID # (4 digits). So Article 1 can be reached at http://www.whatever.com/article.php?0001 . This way I can have a whole article database and be able to manipulate it and call it easily. Tell me if this can be done, and how.

    Thank you for your time.

    ------------------
    ================
    -Khill, www.tsrealm.com
  2. #2
  3. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    15
    Well, I'll try to give you some hints

    First, you need the article page (article.php). I would make something like this:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php

    print( "<p>News-itmes" );

    mysql_connect (localhost, user, password);
    mysql_select_db (dbname);
    $result = mysql_query ("SELECT * FROM tablename ORDER BY id DESC"); // this way you have the latest news-item at the top
    if ($row = mysql_fetch_array($result)) {
    do {
    print( "<p><table width=100% border=0>" );
    print( "<tr><td bgcolor=0088ff width=400>".$row["subject"]." [ <font color=white>".$row["name"]."</font> ] </td><td bgcolor=#0088ff align=right width=175>".$row["date"]."</td></tr>" ); // the header of the news-file
    print( "<tr><td colspan=2>".nl2br($row["text"])."</td></tr>" ); // the body of the news-item
    print( "</table></p>" );
    }
    while($row = mysql_fetch_array($result)); // it does the above until all items are processed
    }
    else {
    print( "There are no news-items! Sorry =]" );
    }
    ?>

    [/code]

    Now you need the amdin-page. You can use a password or you can simply put the admin page (admin_news.php) on a location others don't know.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php

    /* ADDING NEWS */

    if ($action == "add_news") {

    $date = date("Y-m-d");
    $text_tagless = strip_tags( $text );
    mysql_connect (localhost, user, password);
    mysql_select_db (dbname);
    mysql_query ("INSERT INTO tablename (date,subject,name,text)
    VALUES ('$date','$subject','$name','$text_tagless')
    ");
    }
    ?>

    <p><table border=0 width=100%>
    <tr><td class=theader>Add</td></tr>
    <tr><td>

    <form action=admin_news.php method=POST>
    <input type=hidden name=action value="add_news">
    <p><table width=100% border=0>

    <tr><td>Subject:<br><input type=text name=subject size=47 maxlength=50></td></tr>
    <tr><td>Name:<br><input type=text name=name size=47 maxlength=50></td></tr>
    <tr><td>Text:<br><textarea cols=40 name=text rows=7></textarea></td></tr>

    <tr><td><input type=submit value="Add News"></td></tr>
    </table>
    </form>

    </td></tr>
    </table>

    [/code]

    I think there are more ways to do this but this works fine for me. I'm not sure though how you could protect the admin page best: by a htaccess file in your admin dir or by using a mysql database to store users and let them login by php (or by...).

    Hope this helps!

    Mirax
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    14
    Actually there is something that already does this, it's php-slash, basically just the www.slashdot.org page done in php, if you want to see a working version of it, I have one running here http://fragme.dhs.org and you can get it from http://phplib.netuse.de/ it requires phplib, but it is very nice once it is running.3

    Chris

Similar Threads

  1. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 10:50 PM
  2. Perl script converting GIF and JPG images to BMP ???
    By Deanna475 in forum Perl Programming
    Replies: 20
    Last Post: February 17th, 2004, 06:35 PM
  3. iptables changed after S10network script
    By hunt3r in forum Linux Help
    Replies: 0
    Last Post: February 11th, 2004, 03:51 AM
  4. Replies: 2
    Last Post: February 10th, 2004, 11:03 PM
  5. How can I enable a power user to run this script?
    By Yamadatroy in forum Visual Basic Programming
    Replies: 2
    Last Post: January 19th, 2004, 09:39 PM

IMN logo majestic logo threadwatch logo seochat tools logo