• Hi,

    I am using Isert PHP plugin on my site https://tenants.cliffordsinclair.com.

    I am trying to redirect to relevant page once the user selects both house id and year and then Submit the form. Here is complete code. Please help.

    <div id="home-form"><form id="houses" class="house-select" method="post" name="houses" action="open-url()">
    <div>Select your House ID from the list below
    <select name="house-id">
    <option>RDG002</option>
    <option>RDG004</option>
    <option>RDG009</option>
    <option>RDG011</option>
    <option>RDG012</option>
    <option>RDG014</option>
    <option>RDG014A</option>
    <option>RDG017</option>
    <option>RDG046</option>
    <option>RDG050</option>
    <option>RDG058</option>
    <option>RDG086</option>
    <option>RDG097</option>
    <option>RDG110</option>
    <option>RDG279</option>
    </select></div>
    <div>Select your Tenancy Year
    <select id="student-year" name="student-year">
    <option disabled="disabled"></option>
    <option>2015-16</option>
    </select></div>
    <input id="submit" name="submit" type="submit" value="Submit" />
    </form></div>
    
    [insert_php]
         if(isset($_POST['submit'])) {
            $house = $_POST['house-id'];
            $year = $_POST['student-year'];
            $url = "https://tenants.cliffordsinclair.com/".$house."-".$year;
    }
            function open-url() {
            echo "<script type='text/javascript'>location.href='$url'</script>"; }
            if($_SERVER['REQUEST_METHOD']=='POST'){
           open-url();
    }
    [/insert_php]

    https://www.ads-software.com/plugins/insert-php/

Viewing 1 replies (of 1 total)
  • Plugin Author WillBontrager

    (@willbontrager)

    PHP runs only while the page is loading. After the page is fully in the browser, PHP code is no longer available to the page.

    JavaScript may be a better solution than PHP. If not, if PHP must be used, let me suggest putting your code on a separate web page to test it until it’s working as you want. Replace [insert_php] and [/insert_php] with <?php and ?> for the testing, of course.

    After it’s working on a separate web page, then it can be brought into the WordPress page with the Insert PHP plugin.

    Will

Viewing 1 replies (of 1 total)
  • The topic ‘How could I redirect page through Isert PHP plugin?’ is closed to new replies.