Jump to content

could not get post to an external php script


adrianmak
 Share

Recommended Posts

search

<?php

$page->body .= "Content Search<br/>

<p>
<form action='/pw1/query2.php' method='post'>
<input type='text' id='search' autocomplete='off' name='search'>
<input type='submit' value='submit'>
</form>
<p>

<h4 id='results-text'>Showing results for: <b id='search-string'>Array</b></h4>
<div id='results'></div>
";


include("./main.php");

query2.php

<?php
	// ProcessWire bootstrap
    include('index.php');

	$temp_var = $wire->$input->post->search;
    //$temp_var = $_POST["search"];
    echo($temp_var);

When form submitted to query2.php, no form value echoed.

if I use PHP built-in $_POST , submitted value is echoed.

Link to comment
Share on other sites

@Adrian, your code works.

From reading the api doc  https://processwire.com/api/include/

These two are equivalent, so what syntax you prefer to use is up to you:

$mypage = $wire->pages->get("/about/contact/"); $mypage = wire('pages')->get("/about/contact/"); 

$temp_var = $wire->input->post->search;

$temp_var = wire('input')->post->search;

Aren't they equivalent ?

---------------------------

Read again from my op, I putted a $ sign for the input, that's why it is not working

Edited by adrianmak
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...