Jinput not working for joomla - post

I've been stuck on this problem with no clue as to why this doesn't work.
I'm using Joomla 2.5 and building my own component.
I have a 'Books' and 'Book' view. 'Books' lists all the books from the database and 'Book' is where I add/edit my book item. I'm trying to pass a value from 'Books' to 'Book' but it doesn't work.
I've set up an input text with a value to pass on.
<input type="text" id="test" name="test" value="testvalue" />
views/books/tmpl/default.php
<form action="<?php echo JRoute::_('index.php?option=com_test'); ?>" method="post" name="adminForm">
<table class="adminlist">
<thead><?php echo $this->loadTemplate('head');?></thead>
<tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
<tbody><?php echo $this->loadTemplate('body');?></tbody>
</table>
<div>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_('form.token'); ?>
<!-- For sorting -->
<input type="hidden" name="filter_order" value="<?php echo $this->sortColumn; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->sortDirection; ?>" />
<input type="text" id="test" name="test" value="testvalue" />
</div>
</form>
And in my book view.html.php file views/book/view.html.php
$jinput = JFactory::getApplication()->input;
echo 'value:'.$jinput->get('test');
There will be no value. I've tried $_POST('test') but it still doesn't work. Can anyone please point me at the right direction?

The Post data should be received in Controller not in view.
Once you submit the form it should have controller and model to handle the POST data.
check this link and understand the work flow, then on your controller you can try the same code it will works.
Joomla MVC component structure
Hope its helps..

Related

Get value with $_POST from multiple brackets

<input type="text" class="text" id="attachments-1-vid_id" name="attachments[1][vid_id]" value="1qaq0F-SXpo8">
<input type="text" class="text" id="attachments-2-vid_id" name="attachments[2][vid_id]" value="2qaq0F-SXpo8">
<input type="text" class="text" id="attachments-3-vid_id" name="attachments[3][vid_id]" value="3qaq0F-SXpo8">
<input type="text" class="text" id="attachments-4-vid_id" name="attachments[4][vid_id]" value="4qaq0F-SXpo8">
This is my input. I want to check it with only [vid_id]. Is it possible?
If any input posted
if( isset($_POST['vid_id']) ) {
//do it...
}
You are accessing the vid_id index which isn’t really what is passed in the $_POST superglobal.
The solution is based on two assumptions.
Only that input exist.
This is pretty straight forward:
<?php
if(isset($_POST[‘attachments’][231][‘vid_id’]){}
OR
<?php
if(array_key_exists(“vid_id”, $_POST[‘attachments’][231])){}
Similar inputs also exist and you want to perform for multiple inputs.
By this, I mean..
<input type=text name=attachments[][vid_id] />
.....
<input type=text name=attachments[][vid_id] />
<input type=text name=attachments[][vid_id] />
For this, you have to insert it in a loop.
<?php
foreach($_POST[‘attachments’] as $arr){
if(array_key_exists(“vid_id”, $arr){
// do stuff
}
}

Response message after submit button

<form action="http://sms.services/send-sms" method="get">
<input type="number" name="to" />
<input type="text" name="message" />
<input type="hidden" name="app-id" value="108744" />
<input type="hidden" name="password" value="1111111" />
<input type="hidden" name="from" value="TestSender" />
<input type="submit" value="Submit" />
</form>
Hi!
I am trying to display a page with a message like "Message send successfully" when the submit button is clicked. Any ideas?
Thanks in advance
Using PHP
1. create a thank you page.
2. add php code if submit button was clicked that redirects to thank you page Example:
<?php
if(isset($_POST['submit'])){
header("Location: thank_you.php");
}
?>

Why does "<input id='id' type=text name='id' value='H123'>" not get "POST"ed by FormData

When I submit the following form
<form name="fileUpload" id="fileUpload" method="post" action="javascript:void(0);" enctype="multipart/form-data">
<input id='id' type=text name='id' value='H123'>
<div class="file_browser">
<input type="file" name="multiple_files[]" id="_multiple_files" class="hide_broswe" multiple />
</div>
<div class="file_upload">
<input type="submit" value="Upload" class="upload_button" />
</div>
</form>
The files[] get uploaded OK but input "#id" is not in the $_POST array.
I need it because I want to pass the name of the directory that the images are to be stored in.
I notice that you are missing quotation marks around 'text' in
<input id='id' type=text name='id' value='H123'>
Which should be:
<input id='id' type='text' name='id' value='H123'>
Besides that I can't see any obvious reason why it shouldn't work.

How do I add a hidden input tag using the Jericho HTML Parser?

For each form in an HTML page I want to add an additional hidden input tag as it passes through a JEE Filter. For a given HTML page for example:
<html>
<form name="input" action="submit.jsp" method="post">
<input type="hidden" name="id" value="1"/>
<input type="submit" value="Submit"/>
</form>
</html>
the end result should be similar to this:
<html>
<form name="input" action="submit.jsp" method="post">
<input type="hidden" name="id" value="1"/>
<input type="submit" value="Submit"/>
<input type="hidden" name="dynamickey" value="DYNAMIC_VALUE_HERE"/>
</form>
</html>
As the HTML may be malformed, I am figuring that Jericho would be the HTML parser of choice. After a couple of passes through the web pages, I have found ways to change the values of already existing tags, but how to add an additional tag escapes me.
Thanks in advance for help.

Paypal return variables on success page

WHAT I AM TRYING TO DO
I am simply trying to display the results of a Paypal subscription signup. I see the issue of not being able to see the POST variables is a common issue.
I have tried many different ways to do this and I see a common solution is to use:
<input id="rm" name="rm" type="hidden" value="2">
This does not work.
I have tried emailing myself $_POST and $_REQUEST variables and they are empty.
However, my code that detects the txn_type $_POST variable works, since my variables appear in my database. After writing to the database, it is supposed to show a receipt, but does not.
Here's the button code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="paypalemail#gmail.com">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_name" value="Monthly Featured Listings">
<input type="hidden" name="item_number" value="1">
<!-- Set the terms of the regular subscription. -->
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="a3" value="0.01">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="rm" value="2">
<!-- Set recurring payments until canceled. -->
<input type="hidden" name="src" value="1">
<input name="notify_url" value="http://www.example.com/user/register/index.php" type="hidden">
<input name="return" value="http://www.example.com/user/register/index.php" type="hidden">
<input name="cancel_return" value="http://www.example.com/user/register/index.php?payment=cancelled" type="hidden">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" src="http://www.example.com/images/register-and-pay-now.png" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif">
Since my database code works, I can only guess that Paypal is sending the information correctly, but I can't get it to show up in the web page.
My QUESTION
How can I show successful $_POST variables in my page after the redirect?
Well, my guess is that the variables that you are receiving and storing to the database are hitting the notify_url.
These variables are the IPN variables and are not supposed to be shown on any web page.
In order to get information on the specified return URL you have to access the PDT data.
Read more about PDT here

Resources