Welcome Guest, Not a member yet? Register   Sign In
How to insert data from _POST
#1

[eluser]jabga[/eluser]
Hi there.
This is my addnews.php
Code:
<?php

class Addnews extends Controller {

    function addnews()
    {
        parent::Controller();    
    }
    function index ()
    {
        $this->load->view('insertnews');        

    }

This is insertnews.php
Code:
<html>
<body>
<?php $sql="INSERT INTO news (title, content, category)
VALUES
('$_POST[title]','$_POST[content]','$_POST[category]')";
?>
<form action="" method="post">
Title: <input type="text" name="title" />
Content: <input type="text" name="content" />
Category: <input type="text" name="category" />
<input type="submit" />
</form>

</body>
</html>


There are following errors occuring when I click on the submit button
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: title

Filename: views/insertnews.php

Line Number: 7



Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: content

Filename: views/insertnews.php

Line Number: 7


Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: category

Filename: views/insertnews.php

Line Number: 7

How can I add news from insert form easily? Please tell me


Messages In This Thread
How to insert data from _POST - by El Forum - 10-02-2009, 03:44 AM
How to insert data from _POST - by El Forum - 10-02-2009, 03:45 AM
How to insert data from _POST - by El Forum - 10-02-2009, 03:58 AM
How to insert data from _POST - by El Forum - 10-02-2009, 04:11 AM
How to insert data from _POST - by El Forum - 10-02-2009, 04:41 AM
How to insert data from _POST - by El Forum - 10-02-2009, 01:11 PM
How to insert data from _POST - by El Forum - 10-03-2009, 08:22 PM
How to insert data from _POST - by El Forum - 10-03-2009, 09:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB