-6

In here it shows the Title is undefined.Title comes with query.Id comeup with URL.then i fetch the data using given id.

Code

 <?php
    $id = isset($_REQUEST['Id']) ? $id = $_REQUEST['Id'] : '';
    if ($id != 0) {
        include('config.php');
        $sql = "SELECT Id,Title,description,Image,Category from News WHERE Id='" . $id . "'";
        $query = mysql_query($sql);
        $row = mysql_fetch_array($query);
       ?>

        <form action="edit.php" method="POST" enctype="multipart/form-data">

            <div class="OuterWrapper" background-color:white; >
                 <div class="row" id="wrapper" >
                    <div class="col-xs-3" style="margin-top:5%">
                        Title
                    </div>
                    <div class="col-xs-3" style="margin-top:5%">
                        <input type="hidden" name="Title" class="form-control" value="<?php echo $row[0] ?>" >
                        <input type="text" name="Title" class="form-control" value="<?php echo $row[1] ?>" >
                    </div>
                            //SOME HTML CODE HERE


                        </form>

                       <?php 


                        $Title = mysql_real_escape_string($_POST["Title"]);  <-- Undefined Index 'Title'

                        //$description_save = $_POST['description'];
                        //$Category  = $_POST["select_category"];
                        mysql_query("UPDATE News SET Title ='$Title', Description ='$description_save' WHERE Id = '$id'") or die(mysql_error());
                        //echo "Succesfully Updated!";
                        //header("Location: list.php");
                    }
                    ?>

                    </body>
                    </html>
PeeHaa
  • 71,436
  • 58
  • 190
  • 262
TechGuy
  • 4,298
  • 15
  • 56
  • 87
  • 1
    **Warning:** Your code is vulnerable to [SQL injection](http://bobby-tables.com/php) - please stop using the obsolete `mysql_*` functions and switch to a modern database API such as MySQLi / PDO and use prepared statements prevent SQL injection. – Amal Murali Feb 01 '14 at 19:16
  • 1
    Have you done *anything* so far to debug this? Please go through some similar questions (see the *Related* section in the sidebar) and read the answers. – Amal Murali Feb 01 '14 at 19:18

1 Answers1

1

You need to test if Title is actually set. That error occurred because no request with that data was sent.

if(isset($_POST['Title'])) $Title = mysql_real_escape_string($_POST['Title']);

If it still doesn't work, it means there is something wrong with how you are sending the data over

Sterling Archer
  • 22,070
  • 18
  • 81
  • 118