Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Blog CMS problem

  • 07-06-2013 7:25pm
    #1
    Registered Users, Registered Users 2 Posts: 1,298 ✭✭✭


    <?php

    session_start();

    include_once('../includes/connect.php');

    if(isset($_SESSION)){

    if(isset($_POST, $_POST)){

    $title = $_POST;
    $content = $_POST;

    if(empty($title) or empty($content)){
    $error = 'all fields are required';
    }else{
    $query = $pdo->prepare("INSERT * INTO articles(article_title, article_content, article_time) VALUES(?,?,?) ");

    $query->bindValue(1, $title);
    $query->bindValue(2, $content);
    $query->bindValue(3, time());

    $query->execute();

    header('Location: index.php');
    }
    }

    ?>


    <html>
    <head>
    <meta charset="UTF-8">
    <title>Content Management System</title>
    <link rel="stylesheet" type="text/css" href="../css/main.css"/>
    </head>

    <body>

    <div class="container">
    <a href="index.php" id="Logo">
    <h1>CMS</h1>
    </a>
    <Br>


    <h4>Add Article</h4>

    <?php if(isset($error)){ ?>
    <small style="color:#aa0000"><?php echo $error; ?></small>
    <br><Br>
    <?php }?>

    <form method='add.php' method='post' autocomplete='off'>
    <input type='text' name='title' placeholder='title'/>
    <br><br>
    <textarea rows='15' cols ='50' name='content' placeholder='content'></textarea>
    <br><br>
    <input type='submit' value='Add Article'/>
    </form>


    </div>


    </body>
    </html>



    <?php
    }else{

    header('location: index.php');

    }

    ?>



    Am I missing something extremely obvious with this? this is the page for adding articles... its really starting to annoy me that it wont upload or display an error message!


Comments

  • Registered Users, Registered Users 2 Posts: 3,888 ✭✭✭cgarvey


    I can't help you, but others might find it easier to help you if use code tags, and specify what blog/CMS you are using.

    Won't upload? So you can't FTP/sFTP/SCP this up to your host and run it at all? Or it uploads but just gives an empty page when you try an access it? If it won't upload, there's not much chance it'll display anything, never mind a meaningful error message!

    If it is uploading, but not executing/displaying, my standard approach would be to start printing/echoing debug output in your PHP code at the top (breaking the headers, but that's OK for quick debug). Start with making sure you have a valid "logged_in" value in your session, etc.


  • Registered Users, Registered Users 2 Posts: 1,298 ✭✭✭off.the.walls


    I'm using a localhost and a localhost data base to test it at the moment.

    when i try upload article content from the page to the database it wont upload.

    I've run through the code over and over, checked it against corrections on the tutorials i'm using and the poxy thing still wont work!


  • Registered Users, Registered Users 2 Posts: 3,888 ✭✭✭cgarvey


    OK, so substitute "upload" for "submit" or "POST", and the techies will understand your query much better.

    I'd start with:
    1) Does any PHP work? E.g. try a test.php file with only
    <?php phpinfo() ?>
    
    2) Is the database working ok, and can your PHP connect to it OK

    Then, assuming those two points are OK, I'd add a
    print "Here";
    
    before and after your
    $query->execute();
    
    line. If you only see one "Here", then you have some database issues (check your connection string, and MySQL setup). If you don't see any "Here", then it's likely down to your session code (and/or your cookie settings). For example, your session code looks for the presence of "logged_in" but I don't see where that is being set. So if I was to run your code here, I'd always be redirected to "index.php" (as per the else clause at the end of your code).


  • Registered Users, Registered Users 2 Posts: 1,298 ✭✭✭off.the.walls


    Thanks will give that a shot now.. its connecting to the databse alright because I can see the test lorum ipsum article on the main directory.


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    Also try:

    [PHP]echo "<pre>";
    print_r( $query );
    echo "</pre>";
    [/PHP]
    after executing your query. You can check if your query was successful.


  • Advertisement
Advertisement