473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

on upload file it get submitted.and submit button show no reaction

232 100+
i require following steps
  • browse file
  • click upload button to display csv file
  • then if user finds csv correct he may submit form for update of mysql data
i want to update mysql with csv file but on upload file it get submitted.and submit button show no reaction on click
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $db = mysql_connect("localhost", "root", "") or die("Could not connect.");
  3. if(!$db) 
  4. die("no db");
  5. if(!mysql_select_db("asdf",$db))
  6. die("No database selected.");
  7. $handle = fopen('school.csv', "r");
  8. $firstRow = true;
  9. ?>
  10. <form enctype="multipart/form-data" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
  11. File to sql:<br />
  12. <input size='30' type='file' name='filename'>
  13. <input type="submit" name="upload" value="Upload"></form>
  14. <?php
  15. if (isset($_POST['upload'])) { 
  16.     if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
  17.             echo "<table border='1'>";
  18.             while (($data = fgetcsv($handle, ",")) !== FALSE) {
  19.                echo "<tr><td>".$data[0]."</td><td>".$data[1]."</td><td>".$data[2]."</td><tr/>";
  20.          }
  21.       echo "</table>";    
  22.       ?>
  23.       <input type="submit" name="submit"  value="Submit">
  24.        <?php
  25.    }}
  26.    ?>
  27.    </form>
  28.    <?php
  29.    if (isset($_POST['submit'])) { 
  30.    echo "submit clicked";
  31.    }
  32.         ?>
  33.  
  34.  
  35.  
Oct 2 '16 #1
1 1110
Oralloy
988 Expert 512MB
I'm not PHP expert, but it sounds like your "if (isset($_POST['upload']))" is not executing.

Try building a loop that prints all values in the _POST array above the form. Verify that the values are what you expect them to be.
Oct 2 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
2
by: ivanhoe | last post by:
All articles and tutorials I've seen on subject of forms say that if there's name and value for submit button(input tag with type="submit"), they'll get submitted along with the rest of the...
2
by: anonieko | last post by:
Scenario: You have a page that is TOO slow to refresh. But it allows partial flushing of html contents. I.e. Submit button already appears but you don't want your users to click on it prematurely...
5
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
3
by: tshad | last post by:
Is there a way to use a custom button with the: <Input ID="MyFile" Type="File" RunAt="Server">? This gives you a generic button, but I would like to use my own button that has the same style...
6
by: stellstarin | last post by:
I have a HTML page containing two submit buttons in the same form.When the form is submitted,I want to know through which submit button the form was submitted. Is there any event or property which...
2
by: asiva | last post by:
I am using <INPUT id="File1" type="file" name="File1" runat="server"to upload file to the server. My Questions: 1. Is it possible to check the file size before the file is uploaded other than...
9
by: poml | last post by:
Hello, first time posting on thescripts.com, and I'm in dire need of some help. All I want to do is disable the submit button (not the entire form) onClick, and am wondering if this is possible. ...
2
by: lka527 | last post by:
I am trying to make a site available for someone to *upload* certain type of text file (.txt) that can be parsed by written code. the upload file is available on the main site but I need this to...
0
by: harfanmaulapkm | last post by:
i am trying to automate the process of uploading a file on a https site. There is browse button which allows one to select a file from the computer. I want to know if the path can be fixed for the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.