Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:35:18+00:00 2026-06-18T00:35:18+00:00

I’m doing data entry program based on PHP every thing is working no issue

  • 0

I’m doing data entry program based on PHP every thing is working no issue (still under construction) but there is a problem that I can’t find a solution. The issue is when the database doesn’t have any data the image path wont get registered.

Now I’m using uplodify to upload an image file at the same moment I’m sending some data as well. The data contains a name, contact details and description this will directly be inserted to the DB and I also upload image which will get saved in to a folder and the name get saved in the database. But this processes are handled by two different PHP files one is AddPOIPro.PHP which handles the data adding and the uplodify.php to handle file upload and the updating of the file name.

The first issue I had was uplodify was not adding the file name in the same row as the submitted data so what I did was to get the last ID and decrement it by one and the updated the row that works when there is data but when theirs no data it fails. So what should I do to over come this. Below is my complete scripts thank you for your time.

Form

<?php

/**
 * @author SiNUX
 * @copyright 2013
 */

include ('lId.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="Upl/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="http://malsup.github.com/jquery.form.js"></script>

<script type="text/javascript">
$(function() {
    $('#imgUpload').uploadify({
        'auto'     : false,
        'swf'      : 'Upl/uploadify.swf',
        'uploader' : 'Upl/uploadify.php',
        'height'   : 20,
        'width'    : 200,
    }
        // Put your options here
    });
});
</script>

<script type="text/javascript">
 $(document).ready(function(){
  $("#sendData").click(function(){
    var name  = document.getElementById("Name").value;
    var desc = document.getElementById("Descrip").value;
    var con = document.getElementById("ConInfo").value;
    var dataString = 'Name='+name+'&Descrip='+desc+'&ConInfo='+con;

    $.ajax({
      type:'POST',
      data:dataString,
      url:'AddPoiPro.php',
      success:function(data){
       if(data="Data inserted") {
          //alert("Data  Success");
          document.getElementById('msg').innerHTML= "<div style=\"background-color:#0F0; text-align:center; color: #060\">Data Saved</dive>";
          $('#msg').delay(1500).fadeOut();

        } else {
          //alert("Not Inserted");
          document.getElementById('msg').innerHTML= "<div style=\"background-color:#0F0; text-align:center; color: red\">Data Not Saved</div>";
        }
     } 
   });
  });
});
</script>

<link rel="stylesheet" type="text/css" href="Upl/uploadify.css" />

<title>AddPOI</title>
</head>

<body>
<form method="post" enctype="multipart/form-data" name="form1" id="form1">
  <p>
    <label for="poiid">ID :</label>
    <input type="text" name="poiid" id="poiid" readonly="readonly" style="width:70px;" value="<?php echo $tId; ?>" />
  </p>
  <p>
    <label for="Name">POI Name :</label>

    <input type="text" name="Name" id="Name" />
  </p>
  <p>
    <label for="Descrip" style="alignment-adjust:middle">POI Description :</label>
    <textarea name="Descrip" id="Descrip" cols="45" rows="5"></textarea>
  </p>
  <p>
    <label for="ConInfo">Contact Infomation :</label>
    <textarea name="ConInfo" id="ConInfo" cols="45" rows="5"></textarea>
  </p>
  <p>
    <label for="Img">POI Image</label>
    <input type="file" name="imgUpload" id="imgUpload" />
  </p>
  <p><div id="msg"></div></p>
  <p>  
  <div align="center">
    <input type="button" name="Submit" id="sendData" value="Submit" onclick="$('#imgUpload').uploadify('upload','*');" style="width:100px;" />
    <input type="reset" name="reset" id="reset" value="Rest Data" style="width:100px;" />
  </div>
  </p>
</form>
</body>
</html>

Process PHP

<?php

/**
 * @author SiNUX
 * @copyright 2013
 */

include ('connect.php');

$getId = mysql_query("SELECT ID FROM poiinfo");
$row = mysql_fetch_array($getId);

$poiName = $_REQUEST['Name'];
$poiDes = $_REQUEST['Descrip'];
$poiCon = $_REQUEST['ConInfo'];

if($row['ID']== 1){

    $updLn = "UPDATE `poiinfo` SET `Name`='$poiName',`Des.`='$poiDes',`Contact`='$poiCon' WHERE 1";
    $updDone = mysql_query($updLn);
    if ($updDone){
        echo "Data inserted";
    }else {
        echo "Not Done";
    }  

}else {
 $dbData = "INSERT INTO poiinfo(`Name`, `Des.`, `Contact`) VALUES ('$poiName','$poiDes','$poiCon')";

        $putData = mysql_query($dbData);
        if ($putData){
            echo "Data inserted";
        }else {
            echo "Not Done";
        }
 }       
?>

uplodify php

<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/

include ('../../POIWeb/connect.php');
include ('../../POIWeb/lId.php');


// Define a destination
$path = 'POIWeb/img/';
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $path ; // Relative to the root

/*$verifyToken = md5('unique_salt' . $_POST['timestamp']);

if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];

    // Validate the file type
    $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);

    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);

        echo $fName;
        echo '1';
    } else {
        echo 'Invalid file type.';
    }
}*/

//if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetFile = $targetPath . $_FILES['Filedata']['name'];

    // Validate the file type
    $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);    
    $tId = $tId--;


    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);

        $fName = $_FILES['Filedata']['name'];
        $imgPath = "UPDATE poiinfo SET Img = '$fName' WHERE ID = '$tId'";
        mysql_query($imgPath);  

     echo '1';       

    } else {
        echo 'Invalid file type.';
    }
?>

Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:35:20+00:00Added an answer on June 18, 2026 at 12:35 am

    I found the Solution to my problem had some help form the guys in StackOverflow Below is my full code is any one is having the same problem similar to me you can use this code. And if it works for you pls put a vote for me thank you.

    My Data Entry Form

    <?php
    
    /**
     * @author SiNUX
     * @copyright 2013
     */
    
    include ('lId.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script type="text/javascript" src="Upl/jquery.uploadify.min.js"></script>
    
    <script type="text/javascript">
    $(function() {
        $(function() {
            $('#imgUpload').uploadify({
                'auto'     : false,
                'swf'      : 'Upl/uploadify.swf',
                'uploader' : 'Upl/uploadify.php',
                'height'   : 20,
                'width'    : 200,
                'fileTypeDesc' : 'Image Files',
                'fileTypeExts' : '*.gif; *.jpg; *.png'
        });
            // Put your options here
        });
    });
    </script>
    
    <script type="text/javascript">
     $(document).ready(function(){
      $("#save_data").click(function(){
        var name  = document.getElementById("Name").value;
        var desc = document.getElementById("Descrip").value;
        var con = document.getElementById("ConInfo").value;
    
        var dataString = 'Name='+name+'&Descrip='+desc+'&ConInfo='+con;
    
        $.ajax({
          type:'POST',
          data:dataString,
          url:'AddPoiPro.php',
          success:function(data){
           if(data="Data inserted") {
              //alert("Data  Success");
              document.getElementById('msg').innerHTML= "<div style=\"background-color:#0F0; text-align:center; color: #060\">Data Saved</dive>";
              $('#msg').delay(1500).fadeOut();
            } else {
              //alert("Not Inserted");
              document.getElementById('msg').innerHTML= "<div style=\"background-color:#0F0; text-align:center; color: red\">Data Not Saved</div>";
              $('#msg').delay(1500).fadeOut();
            }
         } 
       });
      });
    });
    </script>
    
    <link rel="stylesheet" type="text/css" href="Upl/uploadify.css" />
    
    <title>AddPOI</title>
    </head>
    
    <body>
    <form method="post" enctype="multipart/form-data" name="form1" id="form1">
      <p>
        <label for="poiid">ID :</label>
        <input type="text" name="poiid" id="poiid" readonly="readonly" style="width:70px;" value="<?php echo $tId; ?>" />
      </p>
      <p>
        <label for="Name">POI Name :</label>
    
        <input type="text" name="Name" id="Name" />
      </p>
      <p>
        <label for="Descrip" style="alignment-adjust:middle">POI Description :</label>
        <textarea name="Descrip" id="Descrip" cols="45" rows="5"></textarea>
      </p>
      <p>
        <label for="ConInfo">Contact Infomation :</label>
        <textarea name="ConInfo" id="ConInfo" cols="45" rows="5"></textarea>
      </p>
      <p>
        <label for="Img">POI Image</label>
        <input type="file" name="imgUpload" id="imgUpload" />
      </p>
      <p><div id="msg"></div></p>
      <p>  
      <div align="center">
        <input type="button" name="Submit" id="save_data" value="Submit" onclick="$('#imgUpload').uploadify('upload','*');" style="width:100px;" />
        <input type="reset" name="reset" id="reset" value="Rest Data" style="width:100px;" />
      </div>
      </p>
    </form>
    </body>
    </html>
    

    My DataProcess PHP

    <?php
    
    /**
     * @author SiNUX
     * @copyright 2013
     */
    
    include ('connect.php');
    
    $getId = mysql_query("SELECT ID FROM dbname");
    $row = mysql_fetch_array($getId);
    
    $poiName = $_REQUEST['Name'];
    $poiDes = $_REQUEST['Descrip'];
    $poiCon = $_REQUEST['ConInfo'];
    
    if($row['ID']== 1){
    
        $updLn = "UPDATE `poiinfo` SET `Name`='$poiName',`Des.`='$poiDes',`Contact`='$poiCon' WHERE 1";
        $updDone = mysql_query($updLn);
    
        if ($updDone){
            echo "Data inserted";
        }else {
            echo "Not Done";
        }  
    
    }else {
        $dbData = "INSERT INTO poiinfo(`Name`, `Des.`, `Contact`) VALUES ('$poiName','$poiDes','$poiCon')";        
        $putData = mysql_query($dbData);
    
        if ($putData){
            echo "Data inserted";
        }else {
            echo "Not Done";
        }
     }       
    ?>
    

    This was really tricky the uploadify PHP but got it to work the way I want.

    Uplodify PHP (My Version)

    <?php
    /*
    Uploadify
    Copyright (c) 2012 Reactive Apps, Ronnie Garcia
    Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
    */
    
    include ('../../POIWeb/connect.php');
    include ('../../POIWeb/lId.php');
    
    
    // Define a destination
    $path = 'POIWeb/img/';
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $path ; // Relative to the root
    
    /*$verifyToken = md5('unique_salt' . $_POST['timestamp']);
    
    if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
        $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
    
        // Validate the file type
        $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
        $fileParts = pathinfo($_FILES['Filedata']['name']);
    
        if (in_array($fileParts['extension'],$fileTypes)) {
            move_uploaded_file($tempFile,$targetFile);
    
            echo $fName;
            echo '1';
        } else {
            echo 'Invalid file type.';
        }
    }*/
    
    //if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $targetFile = $targetPath . $_FILES['Filedata']['name'];
    
        // Validate the file type
        $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
        $fileParts = pathinfo($_FILES['Filedata']['name']);    
        $tId = $tId--;
    
    
        if (in_array($fileParts['extension'],$fileTypes)) {
            move_uploaded_file($tempFile,$targetFile);
    
            $fName = $_FILES['Filedata']['name'];
            $imgPath = "UPDATE poiinfo SET Img = '$fName' WHERE ID = '$tId'";
            mysql_query($imgPath);  
    
         echo '1';       
    
        } else {
            echo 'Invalid file type.';
        }
    ?>
    

    This script is working flawlessly now if some face the same situation which I faced use this and see if it works for you and you’re allowed to make any changes as well.

    Thank you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I want to construct a data frame in an Rcpp function, but when I
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I am doing a simple coin flipping experiment for class that involves flipping a
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.