Jump to content

Recommended Posts

Posted

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.

Posted (edited)

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

Yes, they are equivalent, but you had:

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

instead of:

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

Note the $ before input in your version. Sorry I should have explained a little more completely :)

  • Like 3

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
  • Recently Browsing   0 members

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