Jump to content

PHP cms via phpacademy


rangersko

Recommended Posts

OK i am trying to add a posters id/username onto my mysql database. I added a table and 
i am making a progress but the only part i am stuck on is the php side... I get no more errors when i create the article but it doesnt post onto mysql, it just refreshes the page kinda thing.

In artictles.php in templates
<textarea cols="40" rows="1" name="postid" disabled="disabled"><?php echo $user->username(); ?></textarea><br />


In articles.php in admin
if (isset($_POST['title'], $_POST['content'], $_POST['postid'])) {
        $title = $_POST['title'];
        $content = $_POST['content'];
        $postid = $_POST['postid'];

if (!isset($error)) {
            $article->add($title, $content, $postid);

 
I think this part is the wrong part
public function add($title, $content, $postid) {
        global $pdo;

        $query = $pdo->prepare('INSERT INTO articles (article_title, article_content, artictle_postid ,article_timestamp) VALUES (?, ?, ?, ?)');

        return $query->execute(array(
            $title,
            $content,
            $postid,
            time()
        ));
Link to comment
https://forums.phpfreaks.com/topic/280726-php-cms-via-phpacademy/
Share on other sites

More code would be helpful in solving this.

 

I'm guessing you ARE getting errors, but aren't seeing them. Can you check your error_logs?

 

If you actually aren't getting any errors and nothing is being inserted into that table, then the add() function isn't executing, meaning the $error variable is probably set.

 

Remember, a variable can be empty, but still "set."

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.