chaseman Posted January 21, 2011 Share Posted January 21, 2011 Seems to be a basic question, but I couldn't find an answer nor figure it out on my own. Basically I have a script that takes out specific data out of the database, the script works on its own, now I just need a way to make the user execute it with a link or a button. Example: Category: [smileys] - [Category2] - [Category3] - etc. As soon as the user clicks on [smileys] all data in the database which contains the word smileys in the category field gets selected and outputted as a list. Again the script works, I just need to be able to execute it with a button. If I understood it correctly I have to run the script by adding a if (isset($_POST['Smileys'])) { in front of the script. But how do I build the connection with the text link? Quote Link to comment https://forums.phpfreaks.com/topic/225264-make-a-link-execute-a-script/ Share on other sites More sharing options...
chaseman Posted January 22, 2011 Author Share Posted January 22, 2011 I got it to work with: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type='submit' name='Smileys' value='Smileys' /> </form> How can I make it work with a text link as well? Quote Link to comment https://forums.phpfreaks.com/topic/225264-make-a-link-execute-a-script/#findComment-1163385 Share on other sites More sharing options...
trq Posted January 22, 2011 Share Posted January 22, 2011 A simple example.... function smileys() { echo "In here you would have your sileys code"; } if (isset($_GET['action'] && $_GET['action'] == 'smileys') { smileys(); } echo '<a href="?action=smileys">Execute Smileys</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/225264-make-a-link-execute-a-script/#findComment-1163418 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.