How to post value to multi php page?

后端 未结 4 1946
滥情空心
滥情空心 2021-01-22 20:28

the input button is in index.php

相关标签:
4条回答
  • 2021-01-22 20:37

    You could try reloading your page with

    <img src="1.php?search=foo" alt="" />
    <img src="2.php?search=foo" alt="" />
    <img src="3.php?search=foo" alt="" />
    

    To do this you could write index.php like this

    <?php
    $search = isset($_GET['search']) ? $_GET['search'] : '';
    ?>
    <form action="" method="get">
        <input type="text" name="search" id="search" class='search'/>
        <input type="image" src=""  value="Search" class="search_button" /><br />
    </form>
    <?php
    if($search !== '') {
    ?>
        <img src="1.php?search=<?php echo $search; ?>" alt="" />
        <img src="2.php?search=<?php echo $search; ?>" alt="" />
        <img src="3.php?search=<?php echo $search; ?>" alt="" />
    
    <?php
    }
    ?>
    
    0 讨论(0)
  • 2021-01-22 20:39

    Make "page.php" and include the files like:

    include "image1.php";
    include "image2.php";
    include "image3.php";
    

    But don't forget to store the images instead of outputting them.

    You also could put the values in an $_SESSION, and use something like this:

    <img src="<?php echo "image1.php";?>" alt="" />
    <img src="<?php echo "image2.php";?>" alt="" />
    <img src="<?php echo "image3.php";?>" alt="" />
    
    0 讨论(0)
  • 2021-01-22 20:48

    Not entirely sure I follow what you are trying to do here- if each of the three pages outputs an image, why not go straight to the final page and have three <img ../> tags - each one with the src of the appropriate php script which outputs the image.

    So simply direct to index.php, and index.php includes:

    <img src='<?php echo "image1generator.php";?>' alt='' />
    <img src='<?php echo "image2generator.php";?>' alt='' />
    <img src='<?php echo "image3generator.php";?>' alt='' />
    

    This will be on the bases that the imagexgenerator.php scripts output an actual image (with appropriate headers), if not...just use a series of 'include' statements.

    0 讨论(0)
  • 2021-01-22 20:56

    You cannot use standard HTML forms to send requests to three different pages in this way. A form is designed to send an HTTP request to only one location.

    Ideally, you would have a single target.php file which then calls files 1.php 2.php and 3.php on the server through include, merges the results, and sends them back to the user.

    Failing that (for instance, some of the files are on different servers), you could use redirection: 1.php redirects to 2.php when it's done, and so on.

    0 讨论(0)
提交回复
热议问题