Jump to content

add page is not adding to database


KevHopwood

Recommended Posts

hi all.

 

Creating a cms and am adding an add page.

 

my code for add.php is:

<?php

session_start();

include_once('../include/connection.php');

if (isset($_SESSION['logged_in'])){
      if (isset($_POST['title'], $_POST['content'])) {
             $title = $_POST['title'];
             $content = nl2br($_POST['content']);
             $image = $_POST['Image URL'];
             $link = $_POST['Link'];
             $price = $_POST['Price'];

if (empty($title) or empty($content)) {
             $error = 'All Fields Are Required!';
}else{
  $query = $pdo->prepare('INSERT INTO apps (app_title, app_content, app_img, app_link, app_price) VALUES(?, ?, ?, ?, ?)');
     $query->bindValue(1, $title);
     $query->bindValue(2, $content);
     $query->bindValue(3, $image);
     $query->bindValue(4, $link);
     $query->bindValue(5, $price);

     $query->execute();
    header('location: index.php');
}

}
          ?>

<html>
<head>
<title>testing</title>
<link rel="stylesheet" href="../style.css" />
</head>

<body>
<div class="container">
<a href="index.php" id="logo">CMS</a>

<br />


<h4>Add Article</h4>

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

<form action="add.php" method="post" autocomplete="off">

<input type="text" value="" name="title" placeholder="Title" /><br /><br />
<textarea rows="15" cols="50" value="" placeholder="Content" name="content"></textarea><br /><br />
<input type="text" value="" name="Image URL" placeholder="Image URL" /><br /><br />
<input type="text" value="" name="Link" placeholder="Link" /><br /><br />
<input type="text" value="" name="Price" placeholder="Price" /><br /><br />
<input type="submit" value="Add Article" />

</form>

</div>
</body>
</html>


<?php
}else{
       header('location: index.php');
}

?>

my trouble is. it does not add to the database and there for I am unable to add content.

 

can anyone see why?

 

(cpanel error log is turned on and not telling me there is an error)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.