1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Php Script That Creates Posts In Html File ?

Discussion in 'PHP' started by zeerak ahmad, Nov 16, 2013.

  1. #1
    I need a php script that can create a posts in my site . For example see this :
    www.narutohaze.com/news/obito . I want a php script that can edit this html post heading and the image below only and post it with other name like 123.com/news/anything.html ? . Is it possible ? . I need a script in which i can simply put image and post ? . with same design of my site ?
     
    zeerak ahmad, Nov 16, 2013 IP
  2. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #2
    Your post isn't too clear. What do you actually want:
    • A content management system? Plenty of options available, use search.
    • Or a simple script that will use some text you input to generate a static HTML file from a template? That is still a CMS and there are ones out there that generate static HTML pages, rather than dynamic. Again, use a search engine and you will find plenty to choose from.
    • Or scrape content from another site and "customise" it as your own? (This is a big NO, unless you have permission from the content owner.)
     
    ryan_uk, Nov 16, 2013 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,498
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #3
    And are you trying to buy, or you want advice on a suitable script and how to customise?
     
    sarahk, Nov 16, 2013 IP
  4. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #4
    you want an interface for you?
    so you can update the header/body /content/images?

    if that's what you mean, you'll be altering the pages so they wont index because they'll be dynamic changing.
    Otherwise you can save them while also using dynamic interface.

    Use a PHP script that places content to a $body
    for <body> HTML tag

    and make the PHP script grab a file (body.txt file) perse
    make yourself an interface with a textarea box where you post the new body text and submit it like a form
    the string gets passed $_POST method...and fwrites writes it to a text file

    then your HTML page where the <Body> tag is at.. will then have a <?php includes('body.txt')
    and your header and all HTMl code can be posted to your interfaceincluding <H1> New Article </H1>

    it will then render to your HTML page in HTML as a header tag.
    keep your interface offline so nobody can inject it and that will save you time in building an interface that doesnt need umpteen injection/sanitation codes to it.

    IF that's even what you're asking....but I'm sensing that's what you're asking about
     
    ezprint2008, Nov 16, 2013 IP
  5. zeerak ahmad

    zeerak ahmad Greenhorn

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #5
    No No you dont understand Listen see this :
    For example : This is my empty source ( design ) for exp :

    <!DOCTYPE html>
    <html>
    <body>

    <h1>#</h1>

    <p>#</p>

    </body>
    </html>

    ----------------------
    I want a php script that is simple and easy to use in which i can put
    Heading : And it will replace <h1>#</h1> with <h1>133</h1>
    Like a wordpress ^^ . And then i can publish it on site with 123 or something.html :)

    Just this so does anyone understand now ?
     
    zeerak ahmad, Nov 17, 2013 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,498
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #6
    It's not that simple. At best you'd need ajax to generate the field, and send it to the back end script for processing, saving as a file or into the database. And you need to make it really, really secure or your site will be defaced in no time.

    Why not just do it properly and use a CMS (like WordPress).

    Advantages
    • quick setup
    • other people stress over security, you just have to make sure you update the new releases
    • you don't have to write code
    • changes to menus, content will be instant across all files
     
    sarahk, Nov 17, 2013 IP
  7. WebDeveloperSahil

    WebDeveloperSahil Active Member

    Messages:
    331
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    80
    #7
    I know what you want, you want a php script that process it's script and creates/saves an HTML page. It's possible using mybb forum script as every post is saved as HTML. Do you need CMS or just idea about how to do it?
     
    WebDeveloperSahil, Nov 17, 2013 IP
  8. zeerak ahmad

    zeerak ahmad Greenhorn

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #8
    Yes its like that . Im tired of putting manualy image and a heading on my site posts like this : www.narutohaze.com/news/obito . I need a script in which i can simply put a image link and heading and press enter so that the file can easily make a new post with 123.html
     
    zeerak ahmad, Nov 17, 2013 IP
  9. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #9
    You want to install a proper CMS, is what you want. As others have suggested, Wordpress is good for this - if you run it on wordpress.com you can use your own links/domain as well, you don't have to have the wordpress.com-domain. So... why make things that aren't meant to be? Just use a proper management system, and you'll have easy way to upgrade in the future, or create more elaborate, custom pages etc.
     
    PoPSiCLe, Nov 17, 2013 IP
    sarahk likes this.
  10. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #10
    It's very easy to find a CMS to generate static HTML using search:

    http://lmgtfy.com/?q=php cms to generate static html

    (Coding one wouldn't be too difficult either. At one point I used Blosxom, but this was Perl based and I ended up writing something similar - for my own use - in PHP.)

    However, you might want something a bit more powerful. cmsmatrix.org has a big list of them (and you can compare them). There are many choices available and not just the popular ones such as WordPress that might be more suitable for you. Choose one that meets your needs, not just because many people recommend it.
     
    ryan_uk, Nov 17, 2013 IP
  11. DeanIM

    DeanIM Greenhorn

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    21
    #11
    It's fairly simple to do this in PHP without a CMS or actually generating static HTML pages (that would be a CPU/memory hog!)
    You want to generate 'fake' HTML pages that actually still work like a PHP page with values, but look like a HTML URL. We will do this by using so-called 'slugs'.
    For example, I have a page which gets called like this in PHP: mysite.com/page.php?id=15
    We're going to make it look like: mysite.com/my-title.html

    What you want to do is save your data to a MySQL database, and add a 'slug' column. Your slug column can be anything like your page id, title, etc, just make sure it has no whitespaces or special characters.

    Have your PHP script work with the 'slug' rather than 'id', so calling your page would be page.php?slug=my-title-here
    Now in your .htaccess file add:
    
    RewriteRule ^news/(.*)\.html page.php?slug=$1
    
    Code (markup):
    This will make everything from your website that looks like /news/my-article.html actually call your PHP script like page.php?slug=my-article.
    In your page.php simply get the corresponding content in an array with an sql query "SELECT * FROM tbl_news WHERE slug = $_GET['slug']"
     
    DeanIM, Dec 11, 2013 IP
  12. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #12
    Ah. The fun things one could do with an unescaped get-variable in a query...
     
    PoPSiCLe, Dec 12, 2013 IP
    ryan_uk and sarahk like this.