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 6238435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:12:50+00:00 2026-05-24T11:12:50+00:00

I am very new to PHP; ADD.PHP – I have a form that collects

  • 0

I am very new to PHP;

ADD.PHP – I have a form that collects the following information 1. name 2. email 3. phone and picture

pictures are stored on a directory folder on my server and then the filename of that photo is stored on my sql table.

VIEW.PHP – all the data in mysql is being displayed in this page including the photo in tabular format including the id of every record. The id being display is a hyperlink in which when clicked you will be directed to a page wherein you can edit the record contents:

below is the code for my EDIT.PHP

 <?php 
 // Connects to your Database 
 mysql_connect("localhost", "user1", "12345") or die(mysql_error()) ; 
 mysql_select_db("test") or die(mysql_error()) ;


 // Check whether the value for jobnumber is transmitted
if (isset($_GET['id'])) {

// Put the value in a separate variable
$id = $_GET['id'];

// Query the database for the details of the chosen jobnumber
$result = mysql_query("select id, name, email,
phone, picture from employees where id = $id");

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = "Invalid query: " . mysql_error() . "\n";
$message .= "Whole query: " . $query;
die($message);
}

// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(),etc.
while ($row = mysql_fetch_array($result)) {
$name = $row['name'];

echo $name. "\n";
echo $row['email'] . "\n";
echo $row['phone'] . "\n";
echo "<img width=500px height=500px src=pics/" . $row['picture'].">" . "\n";

// form tag
echo '<form action="add2.php" method="POST">';
//display name
echo 'Name: <input type="text" name="name" value="';
echo $row['name'];
echo '"><br>';
//display email
echo 'email: <input type="text" name="email" value="';
echo $row['email'];
echo '"><br>';
//display phone
echo 'Phone: <input type="text" name="phone" value="';
echo $row['phone'];
echo '"><br>';
//display photo
echo 'Photo: <input type="text" name="photo" value="';
echo $row['picture'];
echo '"><br>';

echo '<input type="submit" value="Add">';
echo '</form>';

}
} else {
die("No valid data specified!");
}
?>

using this code, the test fields went well but the input box for the photo is blank and when i click the button the photo field in my database will be blank unless i uploaded a new photo?
how can the user change the existing photo? or retain the old photo if not being changed?

  • 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-05-24T11:12:51+00:00Added an answer on May 24, 2026 at 11:12 am

    Assuming your employees.picture column stores the path to the image.

    To upload a new photo, you’re going to need to change a couple of things…

    Your form needs to use the correct encoding type, ie

    <form action="add2.php" method="post" enctype="multipart/form-data">
    

    You also need to provide a “file” input element to accept the new photo, eg

    <input type="file" name="photo">
    

    To see if a new photo has been supplied, simply check (after detecting a valid POST request)

    if ($_FILES['photo']['error'] == UPLOAD_ERR_OK) {
        // file uploaded
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to PHP and I have a small task of displaying a
I'm new to php and zend framework and fill very uncertain about following: For
I'm very new to WordPress and have no PHP or CSS experience... I'm want
I know the title isn't very clear. I'm new to PHP, so there might
I very new to Python, and fairly new to regex. (I have no Perl
I still very new using Subversion. Is it possible to have a working copy
I am very new to creating webservers - and I have had several goes
I am creating a program that is effectively an sprite creator. I'm very new
I am going to create a new web application that is very customized. It
Sorry, I'm very new to PHP, and I can't find anything about this in

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.