Jump to content

Update image in same page without going to link

Recommended Posts

Posted (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 

    <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <h1>  <strong>Finder<br>

    <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" >


    <?php require_once 'linkgenerator.php' ?>


PHP link generator code 

    if (isset($_POST['link'])) {
        if ('src1' === $_POST['link']) {
            header("Location: https://staticlink" . $_POST["inputpart"] . ".png");



Edited by eagle101

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.