Thread: Article Script

    #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. Here is the scenario.

    I need a script that has a form ("form.html"). On this form it has inputs that have names of "name" "id" "date" "article". They type in those fields and press submit. The info in turn goes to articles.php3. How can I get just the articles to be on http://www.tsrealm.com/artciles.php3?id=123 ??

    So if you have any ideas how to do this, let me know. Oh, and one more thing. Do you have to put a VARCHAR limit on a field in a MySQL database? Because sometimes articles can be lengthy. Anways, thank you. Any help is deeply appreciated.

    ------------------
    ================
    -Khill, www.tsrealm.com
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    just i am writing the script for you.

    Here is the complete code + database design..


    form.html

    <html>
    <body>
    <pre>
    <form action="articles.php3" method="post">
    Name :<input type="text" name="name">
    id :<input type="text" name="id">
    date :<input type="text" name="dt">
    article:<input type="text" name="article">
    <input type="submit" name="submit">
    </form>
    </body>
    </html>

    -----------------------
    articles.php3

    -----------------

    <?
    if(isset($submit)){
    // when user clicks on submit button..

    $con=mysql_connect("localhost","username","password");
    // database connectivity string.

    mysql_select_db("databasename",$con);
    //select database

    $query="INSERT INTO articles(name,id,dt,article) VALUES('$name','$id','$dt','$article')";

    //insert query ..

    $result=mysql_query($query,$con);

    if($result){
    echo "Your record has been added to the database successfullyn";
    }else{
    echo "Error!! while adding recordn";
    exit;
    }

    }else{
    //user has not clicked on submit button
    echo "Error!! Access denied";
    exit;
    }

    ?>

    ---------------------------------

    create a table for saving your record in mysql.
    -----------
    create table article(sno int NOT NULL AUTO_INCREMENT PRIMARY KEY,name varchar(30),
    id int(5),dt DATE,article text);

    -------------------------


    Always generate an auto-no(ie ,sno) in your table that would help you later to trace a record very easily from your table.


    <<
    Because sometimes articles can be lengthy.
    >>

    no problem, if you are using a text field.


    Good Luck!!!

    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."


    [This message has been edited by Shiju Rajan (edited July 01, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    45
    Rep Power
    15
    As a follow up to that comment, either a TEXT or a BLOB in MySQL would be appropriate for an article.
    In addition, to have only the /article.php3?id=123 is not possible. It's either all or nothing. The POST method will not display any of the variables in the URL. If there's a specific reason that you want to display the ID number, then just display on the next page they goto. Hope that helps...
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Randolph, NJ
    Posts
    36
    Rep Power
    15
    Yes, polman is right. I need this script to be able to count (starting with 1) the articles. Meaning the first article is 1, and so on, so I don't have to manually keep track of all of the numbers. The second thing I need to be able to do is to recall the specific article's writer(name), title(title), date written(date), and the content of the article(article). So if I wanted to see article 34 on "Cool Crap in PHP" I could have the link http://www.domain.com/articles.php3?id=34
    (and this will give me the name, date, title, and the article itself.)

    I hope this isn't too much trouble. The script you wrote before Shiju is great, but I must be able to call back the specific articles. Let me know if this can be done. Thank you for all of the wonderful help so far.

    ------------------
    ================
    -Khill, www.tsrealm.com

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. iptables changed after S10network script
    By hunt3r in forum Linux Help
    Replies: 0
    Last Post: February 11th, 2004, 03:51 AM
  3. Replies: 2
    Last Post: February 10th, 2004, 11:03 PM
  4. mod_rewrite and Apache 2 cgi script not working
    By jroamo in forum Apache Development
    Replies: 0
    Last Post: February 10th, 2004, 12:22 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