Hi Friends

I am trying to insert into my table. But i am getting an error message as below

Notice: Undefined index: img_path in D:\xampp-portable\htdocs\cgoogle\entergoogle\addpages.php on line 21

Notice: Undefined index: img_path in D:\xampp-portable\htdocs\cgoogle\entergoogle\addpages.php on line 23

can any one please help me to resolve.

my code is

    <?php 
    if(isset($_POST['Submit']))
        {
            $target = time().basename($_FILES['img_path']['name']);
            $folderpath = "../images/content/";
            if(move_uploaded_file($_FILES['img_path']['tmp_name'], $folderpath.$target))
            {

                echo $sql = mysql_query("insert into gtcontent(gctitle,gcimg,gccontent,gcpage,gckeywords,gctags,gcstatus)values('".$_POST['cgtitlename']."','".$target."','".addslashes($_POST["cgcontent"])."','".$_POST['cgtype']."','".$_POST['cgkeywords']."','".$_POST['cgtags']."','".$_POST['cgstatus']."')");

            }

         }

    ?>


    <form class="form-horizontal form-separate" method="post" role="form">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h6 class="panel-title"><i class="icon-page-break"></i> Add New Content</h6>
        </div>
        <div class="panel-body">
          <div class="form-group">
            <label class="col-md-1 control-label">Title:</label>
            <div class="col-md-11">
              <input type="text" name="cgtitlename" class="form-control" required>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-1 control-label">Image:</label>
            <div class="col-md-11">
              <input type="file" name="img_path" id="img_path" class="form-control" required>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-1 control-label">Content:</label>
            <div class="col-md-11">
              <textarea class="editor" name="cgcontent" placeholder="Enter text ..." required></textarea>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-1 control-label">Page Type:</label>
            <div class="col-md-11">
              <select name="cgtype" data-placeholder="Choose a Type..." class="select-full" tabindex="3" required>
                <option value=""></option>
                <?php
                    $ar = mysql_query("select * from gpagetype order by gid");
                    while($ars = mysql_fetch_array($ar))
                    {
                ?>
                <option value="<?php echo $ars["gpage"]; ?>"><?php echo $ars["gpage"]; } ?></option>
              </select>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-1 control-label">Keywords:</label>
            <div class="col-md-11">
              <input type="text" name="cgkeywords" class="form-control" required>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-1 control-label">Tags:</label>
            <div class="col-md-11">
              <input type="text" name="cgtags" class="form-control" required>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-1 control-label text-left">Status:</label>
            <div class="col-md-11">
              <label class="radio-inline radio-green">
                <input type="radio" name="cgstatus" class="styled" value="Y" checked="checked">
              Active</label>
              <label class="radio-inline radio-red">
                <input type="radio" name="cgstatus" value="N" class="styled">
              InActive</label>
            </div>
          </div>
          <div class="form-actions text-right">
            <input name="Reset" type="reset" class="btn btn-danger" value="Cancel">
            <input name="Submit" type="submit" class="btn btn-primary" value="Submit">
          </div>
        </div>
      </div>
    </form>
    <!-- /separated form inside panel -->

Recommended Answers

All 2 Replies

Put enctype="multipart/form-data" at your form definition:

<form class="form-horizontal form-separate" method="post" role="form" enctype="multipart/form-data">

Thanks albucurus.

It working fine

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.