Barand Posted April 7, 2020 Share Posted April 7, 2020 Are you sure the php file names match? Or is that just a typo? It works for me with an image there. Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576519 Share on other sites More sharing options...
larry29936 Posted April 7, 2020 Author Share Posted April 7, 2020 Typo on my part but not working here. It opens a page with the address of: http://test/mydloader(download/foxclone34-02.iso) and I get a 404 error even though I have it set in the top of my index.php as: <?php $filename = NULL; session_start(); // start of script every time. // setup a path for all of your canned php scripts $php_scripts = '/home/larry/web/test/php/'; // a folder above the web accessible tree // load the pdo connection module require $php_scripts . 'PDO_Connection_Select.php'; require $php_scripts . 'GetUserIpAddr.php'; require $php_scripts . 'mydloader.php'; etc, etc The actual line in my code is: <a href=mydloader(<?php echo "{$iso}";?>)><img src="images/button_get-the-app.png" alt=""> </a> Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576528 Share on other sites More sharing options...
Barand Posted April 7, 2020 Share Posted April 7, 2020 if you view the page source, what does it look like? Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576529 Share on other sites More sharing options...
larry29936 Posted April 7, 2020 Author Share Posted April 7, 2020 Typical 404 page <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL was not found on this server.</p> <hr> <address>Apache/2.4.29 (Ubuntu) Server at test Port 80</address> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576530 Share on other sites More sharing options...
Barand Posted April 7, 2020 Share Posted April 7, 2020 6 minutes ago, Barand said: if you view the page source, what does it look like? Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576531 Share on other sites More sharing options...
larry29936 Posted April 7, 2020 Author Share Posted April 7, 2020 The page source for the 404 page is above. The code for mydloader.php follows: <?php //include 'PDO_Connection_Select.php'; # YOUR CONNECTION //$db = pdoConnect('test'); # GOES HERE if (isset($_GET['ip'])) { $add = $db->prepare("INSERT INTO download (IP_ADDRESS, FILENAME) VALUES (?, ?)"); $add->execute( [ $_GET['ip'], $_GET['filename'] ] ); header('Content-Type: octet-stream'); header('Content-Disposition: attachment; filename="'.$_GET['filename'].'"'); header('Pragma: no-cache'); header('Expires: 0'); readfile("download/{$_GET['filename']}"); } ?> I had to comment the connection lines out because of errors (the db is already connected at start of index.php) Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576532 Share on other sites More sharing options...
Barand Posted April 7, 2020 Share Posted April 7, 2020 View the page HTML source of the page containing the link that your php code created. When that page is displayed in your browser, select "View source" to see what the html is for that link. Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576534 Share on other sites More sharing options...
larry29936 Posted April 7, 2020 Author Share Posted April 7, 2020 (edited) You've got me confused. I never get to the mydload.php page to "View source". When I click on the link, it immediate goes to a 404 error page with an address of http://test/mydloader(download/foxclone34-02.iso) and the following "View source": <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL was not found on this server.</p> <hr> <address>Apache/2.4.29 (Ubuntu) Server at test Port 80</address> </body></html> Should I take it out of the required section and move it to /public_html? Edited April 7, 2020 by larry29936 Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576537 Share on other sites More sharing options...
Barand Posted April 7, 2020 Share Posted April 7, 2020 I am not talking about the mydloader.php page. I … am ... talking … about … the … page … that … contains … the ... link/image … that … you … are … clicking … on 18 minutes ago, Barand said: HTML source of the page containing the link Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576538 Share on other sites More sharing options...
larry29936 Posted April 7, 2020 Author Share Posted April 7, 2020 I didn't know if you wanted the whole thing or not so I gave you everything. Scroll down to the download section for the link. <?php $filename = NULL; session_start(); // start of script every time. // setup a path for all of your canned php scripts $php_scripts = '/home/larry/web/test/php/'; // a folder above the web accessible tree // load the pdo connection module require $php_scripts . 'PDO_Connection_Select.php'; require $php_scripts . 'GetUserIpAddr.php'; require $php_scripts . 'mydloader.php'; //******************************* // Begin the script here $ip = GetUserIpAddr(); if (!$pdo = PDOConnect("foxclone")): { echo "Failed to connect to database" ; exit; } else: { $stmt = $pdo->prepare("INSERT INTO download (IP_ADDRESS, FILENAME) VALUES (?, ?)"); $stmt->execute([$ip,$filename]) ; } endif; ?> <DOCTYPE html> <html lang="en"> <head> <title>Foxclone</title> <!-- <meta content-type="text/html" charset="utf-8"> --> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Links --> <link href="https://fonts.googleapis.com/css?family=Montserrat:500,700&display=swap&subset=latin-ext" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,400i,600&display=swap&subset=latin-ext" rel="stylesheet" /> <link href="css/bootstrap.css" rel="stylesheet" /> <link href="css/fontawesome-all.css" rel="stylesheet" /> <link href="css/swiper.css" rel="stylesheet" /> <link href="css/magnific-popup.css" rel="stylesheet" /> <link href="css/styles.css" rel="stylesheet" /> <!-- a helper script for vaidating the contact form--> <script language="JavaScript" src="js/gen_validatorv31.js" type="text/javascript"></script> <!-- Favicon --> <link rel="icon" href="images/favicon.png" /> <style> .container { display: flex; max-width: 1800px; /* margin-right: auto; margin-left: auto; */ padding-top: .3rem; padding-bottom: 1.5rem; } .divL, .divR { box-sizing: border-box; padding: 5px; border-right: solid 1px #000000; border-left: solid 1px #000000; } .divL { background: #eaeaea; width: 50% ; } .divR { background: #eaeaea; width: 50% ; } .divR h1 { font-size:24px; font-weight:bold; margin-bottom:8px; border-bottom:solid 1px #000000; padding-bottom:10px; text-align: center; } .divR h2 { font-size:18px; font-weight:bold; margin-bottom:4px; padding-bottom:5px; text-align: center; } .divR h4 { font-size:16px; font-weight:normal; margin-bottom:4px; padding-bottom:5px; text-align:left; } .divL h1 { font-size:24px; font-weight:bold; margin-bottom:8px; border-bottom:solid 1px #000000; padding-bottom:10px; text-align: center; } .divL h2 { font-size:18px; font-weight:bold; margin-bottom:4px; padding-bottom:5px; text-align: center; } .divL h4 { font-size:16px; font-weight:normal; margin-bottom:4px; padding-bottom:5px; text-align: left; } .p { font-size:16px; color:#000000; font-weight:normal; margin-bottom:8px; padding-bottom:10px; } .h1 { font-size:24px; font-weight:bold; margin-bottom:4px; border-bottom:solid 3px #000000; padding-bottom:5px; text-align: center; } </style> </head> <body data-spy="scroll" data-target=".fixed-top"> <!-- Preloader --> <div class="spinner-wrapper"> <div class="spinner"> <div class="bounce1"></div> <div class="bounce2"></div> <div class="bounce3"></div> </div> </div> <!-- end of preloader --> <!-- Navbar --> <nav class="navbar navbar-expand-md navbar-dark navbar-custom fixed-top"> <!-- Mobile Menu Toggle Button --> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-awesome fas fa-bars"></span> <span class="navbar-toggler-awesome fas fa-times"></span> </button> <!-- end of mobile menu toggle button --> <div class="collapse navbar-collapse" id="navbarsExampleDefault"> <ul class="navbar-nav ml-auto"> <li class="nav-item"> <a class="nav-link page-scroll" href="#header">HOME <span class="sr-only">(current)</span></a> </li> <li class="nav-item"> <a class="nav-link page-scroll" href="#features">FEATURES</a> </li> <li class="nav-item"> <a class="nav-link page-scroll" href="#legal">LEGAL</a> </li> <li class="nav-item"> <a class="nav-link page-scroll" href="#contact">CONTACT</a> </li> <li class="nav-item"> <a class="nav-link page-scroll" href="#download">DOWNLOADS</a> </li> <br><br> </ul> </div> </nav> <!-- end of navbar --> <!-- end of navbar --> <!-- Header --> <header id="header" class="header"> <div class="header-content"> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="text-container"> <h1>FoxClone</h1> <p class="p-heading p-large">FoxClone is a Linux based image backup, restore and clone tool using a simple point and click interface. It takes images of the partitions on your hard disk (HDD) or solid-state drive (SSD) and stores them for later restoration. Image files can optionally be compressed to save space.</p> <p> </p> </div> </div> <!-- end of col --> </div> <!-- end of row --> </div> <!-- end of container --> </div> <!-- end of header-content --> </header> <!-- end of header --> <!-- end of header --> <!-- Features --> <div id="features" class="download"> <!-- <div class="container"> --> <div class="row"> <div class="download"> <br /><br> <h1><center>We've made it easy to backup or clone partitions or entire drives</center></h1> <div class="container"> <div class="divL"> <h2><center>Simple Interface<center></h2> <h4>Just four simple tabs to take you to each function. No confusing configuration or input is required. Just point and click.</h4> </div> <div class="divR"> <h2><center>Backup & Restore</center></h2> <h4>Backup any partition on a drive or all of them. Windows and linux partition types, legacy and GPT partition tables. Backups are compressed to save space.</h4> </div> <div class="divL"> <h2><center>Clone Full Disks</center></h2> <h4>Clone direct drive to drive or clone from a backup. Clone from a larger drive to smaller drive (with limitations).</h4> </div> <div class="divR"> <h2><center>Additional Tools</center></h2> <h4>Gparted and testdisk are included. Gparted is a disk partitioning tool, testdisk is for data recovery.</h4> </div> <div class="divL"> <h2><center>Built-In Document Viewer</center></h2> <h4>A step by step manual is available from within the app. If you're unsure what to do next, just open the manual using the built-in document viewer.</h4> <br /><br /><br /><br /><br /><br /> </div> </div> </div> <!-- end of col --> </div> <!-- end of row --> </div> <!-- end of container --> </div> <!-- end of cards-2 --> <!-- end of services --> <!-- ====================================== LEGAL ========================================= --> <div id="legal" class="filter"> <!-- hitwebcounter Code START --> <div class="container"> <div class="row"> <div class="col-lg-12"> <h2>LEGAL</h2> <div class="body"> <p class="p-heading p-large"> This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. <br /><br /> This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. <br /><br /> A copy of the GNU General Public License is available on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You can also obtain it by writing to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. </h3> <br /><br /><br /><br /><br /><br /> </div> </div> </div> <!-- end of col --> </div> <!-- end of row --> </div><br /> </div> <!--===============END LEGAL======================--> <div id="contact" class="stylized"> <br /> <div "myform"> <br /> <h1>Need help? Have a suggestion? Why not send us an email.</h1> <h3><center> You'll receive a copy for your records</center></h3> <br /> <form id="form1" method="POST" action="mail.php"> <label>Name</label> <input type="text" name="name" > <label>Email</label> <input type="text" name="email" > <select name="type" id="category" size="1"> <option value=''>Select A Category</option> <option value='Questions'>Questions</option> <option value="Report Problem">Report Problem</option> <option value='Suggestion'>Suggestion</option> <option value='Other'>Other</option> <option value="Website Problem"> Website Problem</option> </select> <br /><br /> <br /> <label>Message(10 character min.)</label> <textarea name="message" rows="7"></textarea><br /> <button type="submit" value="Send" style="margin-top:15px; margin-left: 500px; text-align: center;">Send Email</button> <!-- <center><input type="image" src="images/button_send-email.png" alt="Email"></center> --> <div class="spacer"></div> <br /><br /><br /><br /><br /><br /> </form> </div> <!-- end of form class --> </div> <br /><br /><br /><br /> <!-- End of Contact --> <!-- DOWNLOAD --> <div id="download" class="stylized"> <div "myform"> <div class="container"> <div class="row"> <div class="download"> <br /><br> <h1><center>FoxClone Download Page</center></h1> <?php $isos = glob('download/*.iso'); $iso = $isos[count($isos) -1]; $isoname = basename($iso); $md5file = md5_file($iso); ?> <?php $pdfs = glob('download/foxcloneV*.pdf'); $pdf = $pdfs[count($pdfs) -1]; $pdfname = basename($pdf); ?> <?php $debs = glob('download/*.deb'); $deb = $debs[count($debs) - 1]; $debname = basename($deb);; ?> <?php $srcs = glob('download/*.tar.*'); $src = $srcs[count($srcs) - 1]; $srcname = ltrim($src,'download/'); ?> <div class="container"> <div class="divL"> <h3>Get the "<?php echo "{$isoname}";?>" file (approx. 600MB)</h3> <!-- $filename = "<?php echo "/{$iso}";?> --> <center> <a href=mydloader(<?php echo "{$iso}";?>)><img src="images/button_get-the-app.png" alt=""> </a> </center> <br /> <h3 style="margin-bottom: 0.5rem;">The MD5sum for "<?php echo "{$filename}";?>" is "<?php echo "{$md5file}";?> <br> ______________________________________________________________________________________________________________________"</h3> <h3>Read or Download the Installation and Use Instructions </h3> <center> <a href="<?php echo "/{$pdf}";?>"><img src="images/button_read-the-file.png" alt=""></a></center> <br /><h3>______________________________________________________________________________________________________________________"</h3> <h3>How To Install To A USB/CD</h3> <h4>1. Download the iso file <br /> 2. a. If burning to a USB stick use the USB image writer that comes with your distribution. <br />     b. If burning to a CD, there are many Linux utilities, xfburn is one of the simplest. Install from your software manager/centre if not installed.</h4> <br /> <h3>How To Boot The USB/CD</h3> <h4>At the manufacturer’s splash screen, press the key to get into the boot menu. This key varies across PCs, as an example for a Lenovo Thinkpad it is F12. Consult your user manual to find out what the key is or google. Do not confuse the boot menu with the boot priority order settings in BIOS. The boot menu is a one time selection for the device to use to boot the PC. It overrides the normal boot priority order. The next time you boot, the PC will revert to the normal boot order. Virtually all BIOSs support this feature, they just do it differently. </h4> </div> <div class="divR"> <h3>Get the "<?php echo "{$debname}";?>" file (approx. 7MB) </h3> <center> <a href="<?php echo "/{$deb}";?>"><img src="images/button_download.png" alt=""></a></center><br /> <?php $filename = $debname; $stmt->execute([$ip,$filename]) ; ?> <h3 style="color:red"><b>WARNING - DO NOT INSTALL THIS TO YOUR COMPUTER !!!</b></h3> <h4 style="color:black">This .deb file is designed to be installed on a large USB drive, typically 1TB or greater, that already has an operating system installed and is intended as a backup drive.</h4> <h4><b>For more information <a href='download/deb_file.pdf' style='color:#ff0099;'>Click Here</a></b></h4> <?php $filename = 'deb_file.pdf' ; $stmt->execute([$ip,$filename]) ; ?> <br><h3>______________________________________________________________________________________________________________________"</h3> <h3>Get the "<?php echo "{$srcname}";?>" Source file (approx. 6MB) </h3> <center> <a href="<?php echo "/{$src}";?>"><img src="images/button_download.png" alt=""></a></center> <?php $filename = $srcname; $stmt->execute([$ip,$filename]) ; ?> </div> </div> </div> </div> </div> </div> </div> <!-- footer ================================================== --> <div id="footer"> <div class="copyright"> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="p-small">Copyright © 2019-2020 Andy Hardwick <br /> Design by Larry Hale</div> <p> <a href="https://jigsaw.w3.org/css-validator/check/referer"> <img style="border:0;width:88px;height:31px" src="https://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /> </a> </p><br /> <!-- hitwebcounter Code START --> <script type="text/javascript" src="https://free-hit-counters.net/count/5gee"></script><br> <a href='https://thesiswritingservice.net/'>author bachelor's thesis</a> <script type='text/javascript' src='https://www.whomania.com/ctr?id=af7ce0098d37aaf2a18654f4fc14d04350b374b2'></script> </div> </div> </div> </div> </div> <!-- end footer__top --> <script src="js/jquery.min.js"></script> <!-- jQuery for Bootstrap's JavaScript plugins --> <script src="js/popper.min.js"></script> <!-- Popper tooltip library for Bootstrap --> <script src="js/bootstrap.min.js"></script> <!-- Bootstrap framework --> <script src="js/jquery.easing.min.js"></script> <!-- jQuery Easing for smooth scrolling between anchors --> <script src="js/swiper.min.js"></script> <!-- Swiper for image and text sliders --> <script src="js/jquery.magnific-popup.js"></script> <!-- Magnific Popup for lightboxes --> <script src="js/morphext.min.js"></script> <!-- Morphtext rotating text in the header --> <script src="js/isotope.pkgd.min.js"></script> <!-- Isotope for filter --> <script src="js/validator.min.js"></script> <!-- Validator.js - Bootstrap plugin that validates forms --> <script src="js/scripts.js"></script> <!-- Custom scripts --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576539 Share on other sites More sharing options...
larry29936 Posted April 7, 2020 Author Share Posted April 7, 2020 (edited) My mistake... here's the page source for that section <div class="container"> <div class="divL"> <h3>Get the "foxclone34-02.iso" file (approx. 600MB)</h3> <center> <a href=mydloader(download/foxclone34-02.iso)><img src="images/button_get-the-app.png" alt=""> </a> </center> <br /> Bet I need to change the code to read "<a href=mydloader.php(<?php echo "{$iso}";?>)><img src="images/button_get-the-app.png" alt=""> </a> Edit: changing to mydloader.php didn't help Edited April 7, 2020 by larry29936 Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576540 Share on other sites More sharing options...
Barand Posted April 7, 2020 Share Posted April 7, 2020 Very little resemblance to the examples I gave you. Why did I bother? Quote Link to comment https://forums.phpfreaks.com/topic/310479-how-to-code-database-insert-on-buttonclick/page/2/#findComment-1576543 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.