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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:51:54+00:00 2026-05-31T22:51:54+00:00

PHP beginner working from a tutorial. I’m trying to do a simple upload from

  • 0

PHP beginner working from a tutorial. I’m trying to do a simple upload from a PHP form to a MySQL database. The form uploads correctly, but every time the page refreshes, it repeats the previous upload, creating duplicate entries. You can see my working page here.

You can see that I’m trying to get the comment “Thank you! Product Added!” to spit out above the table upon submission, but I’ll admit that I’m confused as to exactly what is happening when I hit “Submit”…right now it always shows the confirmation message! I’ve included the PHP code for the form below.

Thanks in advance!

Mike

<div id="form">

<h1 class="green">UPLOAD TO TABLE 'manufacturer'</h1>


<?php

$con = mysql_connect($host,$user,$pass);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("thenally_productdump", $con);

$sql="INSERT INTO manufacturer (manu_name, manu_product_type, manu_product_description, manu_website)
VALUES
('$_POST[manufacturer]','$_POST[product]','$_POST[description]','$_POST[website]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Thank you! Product Added!";

mysql_close($con);

?> 

<form action="" method="post">
<table>
    <tr>
    <td class="form-table-left"><b>Manufacturer: </b> </td>
    <td class="form-table-right"><input type="text" name="manufacturer" size=50></td>
    </tr>

    <tr>
    <td class="form-table-left"><b>Product Type:</b></td>
    <td class="form-table-right"><input type="text" name="product" size=50></td>
    </tr>

    <tr>
    <td class="form-table-left"><b>Product Description: </b></td>
    <td class="form-table-right"><textarea name="description" rows=5 cols=40></textarea></td>
    </tr>

    <tr>
    <td class="form-table-left"><b>Manufacturer Website: </b></td>
    <td class="form-table-right"><input type="text" name="website" value="http://" size=50></td>
    </tr>

    <tr>
    <td class="submit"><input type="submit" name="submit" value="Add Product !"></td>
    </tr>

    </table>
    </form>

</div>
  • 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-31T22:51:55+00:00Added an answer on May 31, 2026 at 10:51 pm

    Mike – everything in the php block will execute whenever your page is loaded. So if you look at the echo line you’ll notice that it always will execute and print out the success text. You need to do several things:

    1. Test your input to see if the form has been submitted properly. This is where you’d test to make sure all your required fields have content. If they do not, then you would show the form again. If they are right, then you show the success message. You could simply test the input using strlen to see if the variables have been populated with something of length >0. Or you could use isset().

    2. You really need to think about security right away. I know you’re just learning with this tutorial example, but it is very easy for someone to do an injection attack on your database if you simply insert the values as you’ve done. You need to look at the man page for mysql_real_escape_string.

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

Sidebar

Related Questions

I'm trying to make an update form. The update part is already working, but
I'm a beginner working on a login script in PHP. This is the form
I'm a beginner in PHP trying implementing a simple registration system for a website.
I am beginner in PHP. I am trying to parse this xml file. <relationship>
I am a total beginner in PHP and writes simple web apps in procedural
I'm a beginner in php, and I am trying to create a login and
I'm a beginner. I write simple json jquery php code to help understand the
I am a beginner in PHP and am working on a script that can
I am php beginner and I am trying to make e-commerce by using php.
I have trouble with creating an approval form as am still php beginner, the

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.