eagle101 Posted March 18, 2020 Share Posted March 18, 2020 (edited) Hello i kinda new to programing mostly learning myself stuf there so i need some help to figure out. so i have lets say static link who always same and i write something in input field and press search button. so i get new link and immediately going to dat link, which means i leaving my site. in my case i working with image so my problem, is it somehow possible to display image in same page while writing someting in input field when presing button and image just change down below not going directly to link ? P.S. sory for my english i have this code <html> <head> <meta charset="utf-8"> <title>Finder</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <center> <h1> <strong>Finder<br> <br> </strong></font></h1> <form action="#" method="POST"> <input type="hidden" name="link" value="src1"> <input type="text" name="inputpart" placeholder="inputpart" size="40"> <input type="submit" name="submit" value="Search" > </form> </center> <?php require_once 'linkgenerator.php' ?> </body> </html> PHP link generator code <?php if (isset($_POST['link'])) { if ('src1' === $_POST['link']) { header("Location: https://staticlink" . $_POST["inputpart"] . ".png"); } } ?> Edited March 18, 2020 by eagle101 Quote Link to comment https://forums.phpfreaks.com/topic/310315-update-image-in-same-page-without-going-to-link/ Share on other sites More sharing options...
maxxd Posted March 18, 2020 Share Posted March 18, 2020 You need to use JavaScript to change page contents without refreshing or redirecting the page. Basically, you'll attach a click handler to your button that reads the contents of your input field, uses AJAX to communicate with a PHP script on the server - it's this script that will figure out what image to serve up - and then replaces the image with the information sent back from the PHP script. Quote Link to comment https://forums.phpfreaks.com/topic/310315-update-image-in-same-page-without-going-to-link/#findComment-1575561 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.