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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:44:17+00:00 2026-06-10T23:44:17+00:00

I’m making a script where the user can upload an image of his pet.

  • 0

I’m making a script where the user can upload an image of his pet. I have this code:

<?php
    session_start();
    $name = $_SESSION['myusername'];
    $petName = $_POST['picup']; // a pet name picked by a dropdown list

    $con = mysql_connect( "localhost", "lalala", "blabla" );
    mysql_select_db( "lalal_animal", $con );
    if ( @$_POST ['submit'] ) {
      $file = $_FILES ['file'];
      $name1 = $file ['name'];
      $type = $file ['type'];
      $size = $file ['size'];
      $tmppath = $file ['tmp_name'];
      if ( $name1 != "" ) {
        if ( move_uploaded_file( $tmppath, 'upload/' . $name1 ) ) {
          $query = "insert into pics(animalName,username,image) VALUES('$petName','$name','$name1')";
          mysql_query( $query ) or die( 'could not updated:' . mysql_error() );
          echo "Your image upload successfully !!";
        }
      }
    }
    ?>

    <html >
      <head>
        <title>Image Upload</title>
      </head>
      <body>
        <form name="form" action="" method="post" enctype="multipart/form-data">
          Photo <input type="file" name="file" />
          <input type="submit" name="submit" value="submit" /> 
        </form>
      </body>
    </html>

After running this the tabele column named: “animalName” is blank.

When I run this SQL command inside of phpmyadmin:

insert into pics(animalName,username,image) VALUES('Sparky','tester','sparky.jpg')

The tables are ok and the animalName column contains the right value.
The pet name is showing, if I do:

echo $petName;

The pet name is comming from another form. The user 1st have to choose the pet and then he’s redirected to the uload form.
Here is the dropdown you requested:

<table width="480" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="upload" method="post" action="upload_form.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Upload image</strong></td>
</tr>
<td>Select a pet</td>
<td>:</td>
<td>

<?php
mysql_connect('localhost', 'blabla', 'lalal');
mysql_select_db('lalala_animal');

$sql = "SELECT name FROM animal where username='$name'";
$result = mysql_query($sql);

echo "<select name='picup'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['name'] . "'>" . $row['name'] . "</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Upload"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

I suspect that there is somthing wrong with the HTML form below of the php code, but I can’t understand what.

  • 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-10T23:44:19+00:00Added an answer on June 10, 2026 at 11:44 pm

    As you said that you pass the $_POST['picup'] from the first submit, just simply modify your second form and put the $_POST['picup'] value in the hidden field. Modify your form like this..

    <form name="form" action="" method="post" enctype="multipart/form-data">
          Photo <input type="file" name="file" />
          <input type="hidden" name="picup" value="<?php echo $petName; ?>" /> 
          <input type="submit" name="submit" value="submit" /> 
        </form>
    

    Hope this will work..

    Because when you submit second, that time your first post values not working.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms
Does anyone know how can I replace this 2 symbol below from the string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.