sbiese Posted May 31, 2013 Share Posted May 31, 2013 Can anyone tell me why this won't work? <a href="<?php require_once('includes/scotch_gard.php'); ?>">Scotchgard Carpet Protector</a> I want it to just display the link text and run the 'require_once' statement when I click it. Thanks, Steve Link to comment https://forums.phpfreaks.com/topic/278641-href-an-require_once/ Share on other sites More sharing options...
jazzman1 Posted May 31, 2013 Share Posted May 31, 2013 Is there an echo inside includes/scotch_gard.php? PS: It's a bad practice by the way! Link to comment https://forums.phpfreaks.com/topic/278641-href-an-require_once/#findComment-1433433 Share on other sites More sharing options...
DavidAM Posted May 31, 2013 Share Posted May 31, 2013 require and include (the their "_once" cousins) bring the code from the specified file into the current file as if you had typed that code right there. If that code outputs anything then the output appears right there. PHP is run on the server, and all of its output is sent to the browser. The browser then renders the (usually) HTML to show the page to the user. If you want that script to be run when the link is clicked, then the link needs to point to a URL that will execute that script. Link to comment https://forums.phpfreaks.com/topic/278641-href-an-require_once/#findComment-1433434 Share on other sites More sharing options...
sbiese Posted June 1, 2013 Author Share Posted June 1, 2013 The 'includes/scotch_gard.php' file contains a javascript drop-in div. Here's how I got it working: <a href="#" onclick="javascript:dropinbox3.show()">Scotchgard Carpet Protector</a> Link to comment https://forums.phpfreaks.com/topic/278641-href-an-require_once/#findComment-1433559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.