0

I am adding an article to database, this code worked fine all these days but suddenly stopped working (didn't messed anything) and I cant find any problem with this code but when ever Ii post something it's returning me failed.

<?php
if (!isset($_POST['submit']))
{
    echo 'hmm';
}
else
{
    //$_POST['title'] = filter_var($_POST['title'], FILTER_SANITIZE_STRING);
    $article_title = $_POST['title'];

    $article_date = date('d-m-y');
    $article_author = $_POST['author'];
    $article_keywords = $_POST['keywords'];
    //$_POST['content'] = filter_var($_POST['content'], FILTER_SANITIZE_STRING);
    $article_content = $_POST['content'];
    $article_category = $_POST['category'];
    $article_image = $_FILES['image']['name'];
    $image_tmp = $_FILES['image']['tmp_name'];

    if ($article_title == '')
    {
        echo "<script> alert('enter a title')</script>";
        exit();
    }
    else
    {
        move_uploaded_file($image_tmp, "images/$article_image");
        $add = "insert into articles(article_title,article_author,article_date,article_keywords,category,article_content,article_image) values ('$article_title','$article_author','$article_date','$article_keywords',$article_category,'$article_content','$article_image')";

        if (mysqli_query($conn, $add) == 1)
        {
            echo "success";
        }
        else
        {
            echo "failed";
        }
    }
}

?>

EDIT : i am getting an error saying i am getting failedChamp 'urdfhghduk'(category input) inconnu dans field list

  • 3
    and have you checked your DB to see if its gone through ? Also any error logs on ? – Pogrindis Feb 06 '15 at 10:46
  • Also suggesting checking errors: http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php – James McClelland Feb 06 '15 at 10:48
  • **Danger**: You are **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that you need to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Feb 06 '15 at 10:50

0 Answers0