When set value of action, post/get don't work - php

I have form:
echo "
<form action='http://domain.com/' method='get'>
<input type='hidden' name='order_id' value='".$_SESSION['shoppingcart_id']."' />
<input type='hidden' name='account_id' value='".$account_id."' />
<input type='hidden' name='action' value='add' />
<input type='submit' class='form-button' value='Buy' />
</form>
";
and get don't get any results.
http://domain.com/
If I set value of action to empty like:
<input type='hidden' name='action' value='' />
the result is:
http://domain.com/?order_id=xxxxxxxx&acount_id=xxxxxxxxx$action=
I'm confused why with empty action get results, but with action don't get anything!?
p.s. With "post" is the same.

Related

Passed data value will stay on page after submitting form

I have a 2 pages and I want to stay the data value that i passed from page1.php
page1.php
<form action='page2.php' method='POST' class='form-inline'>
<input type='submit' class='btn btn-info' value='Manage Child'
name='manage'>;
<input type='hidden' value='<?php echo $id;?>' name='id'>
</form>
page2.php
$id = $_POST['id'];
if(isset($_POST['passinfo'])){
$studentid=$_POST['studid'];
}else{
$studentid='';
}
<form>
<input type='hidden' name='parentid' value='<?php echo $id;?>'
<input type='hidden' name='studentid' value='<?php echo $studentid;?>'
<input type='text' name='studentname'>
</form>
<form action='' method='POST'>
<input type='hidden' name=studid value='<?php echo $stud_id?'>
<input type='submit' class='btn btn-primary' value='Assign' name='passinfo'>
</form>
my problem is if I click the 'passinfo' button and submit the 'studid' value the '$parentid' value will be unindentified variable. My question is how do I maintain the value of the '$parentid' even if I submit a form
You must place hidden inputs in one form:
<form action='' method='POST'>
<input type="hidden" name="parentid" value='<?=$id?>'>
<input type="hidden" name="studentid" value='<?=$studentid?>'>
<input type='hidden' name=studid value='<?=$stud_id?'>
<input type='submit' class='btn btn-primary' value='Assign' name='passinfo'>
</form>

PHP: How to use method GET, if action already contains GET value

I have a form, something like this:
<form action='index.php?page=search&filter=1'>
<input type='text' name='ID'>
<input type='text' name='number'>
<input type='submit'>
</form>
If I submit form, it will go to page:
index.php?ID=value1&number=value2
I would like to have
index.php?page=search&filter=1&ID=value1&number=value2
How can I append extra fields to url ?
Thank you for help.
you should put these values in hidden inputs:
<form action='index.php'>
<input type='hidden' name='page' value='search'>
<input type='hidden' name='filter' value='1'>
<input type='text' name='ID'>
<input type='text' name='number'>
<input type='submit'>
</form>
You can submit additional GET value as a hidden field value in the form which will be submit along with form submission.
<form action="index.php" method="get">
<input type='text' name='ID'>
<input type='text' name='number'>
<input type='hidden' name='page' value='search'>
<input type='hidden' name='filter' value='1'>
<input type='submit'>
</form>
Use hidden fields with your form and you will get exact url you want.
Try below code :
<form action="index.php" method="get">
<input type='hidden' name='page' value='search'>
<input type='hidden' name='filter' value='1'>
<input type='text' name='ID'>
<input type='text' name='number'>
<input type='submit'>
</form>
Try using some hidden input fields and use get method in form submitting.
Try this:
<form action="index.php" method="GET">
<input type='hidden' name='page' value='search' />
<input type='hidden' name='filter' value='1' />
<input type='text' name='ID' value='value1' />
<input type='text' name='number' value='value2' />
<input type='submit' value='Submit' />
</form>

Sending php in a name value which is an html form

<form action='itemEdit.php' method='post' />
<input type='hidden' name='<?php $row['id'];?>' value='' />
<input type='submit' name='submit' value='Edit'
</form>
is it possible to send this php script to the 'itemEdit.php' page and put the row output into a php variable? I've tried this and haven't had any success. I can't figure this out by just using mySql. Thanks
You should do the following..
<form action='itemEdit.php' method='post' />
<input type='hidden' name="YouFieldNameHERE" value="<?php $row['id'];?>" />
<input type='submit' name='submit' value='Edit'/>
</form>
Then in your itemEdit.php you can access it like ...
$fieldValue = $_POST['YouFieldNameHERE'];
You need to use the name attribute to indicate what value you are passing and either use echo or a shorttag or no value will be in the name attribute:
<input type='hidden' name='id' value='<?= htmlentities($row['id']) ?>'>
<input type='hidden' name='id' value='<?php echo htmlentities($row['id']) ?>'>
If you are naming your attribute with the id, it would look like this:
<input type='hidden' name='<?= htmlentities($row['id']) ?>' value=''>
<input type='hidden' name='<?php echo htmlentities($row['id']) ?>' value=''>
The htmlentities helps protect against XSS.
Also be sure to close the submit tag.
If it is HTML5, you don't need the />
two thing one use value for not name for input value.
another use echo or <?= to print value in input
instead of this
<input type='hidden' name='<?php $row['id'];?>' value='' />
use
<input type='hidden' name='inputname' value='<?php echo $row['id'];?>' />
to get value in next page
echo $_POST['inputname'];

Sagepay form submit parameters in PHP

How many parameters I need to pass the in form ULR ,It can interact with sagepay payment gateway. Following parameters are I have passed in the form url but I ma getting the following error:
Error:
Error number:
5068
Error message:
The encryption method is not supported by this protocol version.
I am unable to connect the sagepay server payment.I am completly new about the configuration of sagepay payment.
Some one can please tell me how many parameter I need to pass and What are they are?
How to encrypt the values and then pass the values?
Code:
<form name='sagepay' action='{$pm_sagepay_url}' method='post' onsubmit='this.submit.disabled=true;return true;'>
<input type='hidden' name='VPSProtocol' value='3.00'>
<input type='hidden' name='TxType' value= 'PAYMENT'>
<input type='hidden' name='Vendor' value= 'protxross'>
<input type='hidden' name='Crypt' value= 'TPjs72eMz5qBnaTa'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='business' value='{$this->pm_sagepay_business}'>
<input type='hidden' name='item_name' value='".$order->order_description()."'>
<input type='hidden' name='amount' value='".sprintf("%01.2F", ($order->order_total_price-$order->order_fee))."'>
<input type='hidden' name='handling' value='".($order->order_fee)."'>
<input type='hidden' name='return' value='".$_SHOP->root_secured. 'checkout_accept.php?'.$order->EncodeSecureCode()."'>
<input type='hidden' name='notify_url' value='".$_SHOP->root_secured. 'checkout_notify.php?'.$order->EncodeSecureCode()."&setlang={$_SHOP->lang}'>
<input type='hidden' name='cancel_return' value='".$_SHOP->root_secured. 'checkout_cancel.php?'.$order->EncodeSecureCode()."'>
<input type='hidden' name='currency_code' value='{$_SHOP->organizer_currency}'>
<input type='hidden' name='undefined_quantity' value='0'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='no_note' value='1'>
<input type='hidden' name='rm' value='2'>
<input type='hidden' name='invoice' value='{$order->order_id}'>
<div align='right'>
<input type='submit' value='{!pay!}' name='submit2' alt='{!sagepay_pay!}' >
</div>
</form>";
The info added to the form needs to be encrypted you be better off using the guide found here:
http://www.sagepay.co.uk/file/12241/download-document/FORM_Integration_and_Protocol_Guidelines_010814.pdf?token=gMABp5MzTV1BevfFpoTFkrofFWwHXySRM5tzGIdKj3Q
Also this guy has made a basic script for the form i got the main form to send it was the success page i could not get to work but i have now so if you get stuck give me a shout..
https://github.com/tolzhabayev/sagepayForm-php

paypal form not sending data properly

I am trying to submit the following paypal form through a hosted-payment system. however, it does not seem to be passing through any of the variables apart from the price.
Can anyone see where I am going wrong:
<form action='https://securepayments.paypal.com/cgi-bin/acquiringweb' method='post' target='hss_iframe' id='PayPalForm' name='PayPalForm'>
<input type='hidden' name='cmd' value='_hosted-payment' />
<input type='hidden' name='charset' value='utf-8' />
<input type='hidden' name='currency_code' value='GBP' />
<input type='hidden' name='business' value='seller#email.com' />
<input type='hidden' name='paymentaction' value='sale' />
<input type='hidden' name='template' value='TemplateD' />
<input type='hidden' name='return' value='http://yoursite.com/groupon-success.php' />
<input type='hidden' name='notify_url' value='http://yoursite.com/paypal-groupon- ipn.php' />
<input type='hidden' name='item_name' value='Item name' />
<input type='hidden' name='item_number' value='4' />
<input type='hidden' name='subtotal' value='0.01' />
<input type='hidden' name='custom' value='41' />
<input type='hidden' name='address_override' value='true' />
<input type='hidden' name='first_name' value='Jack' />
<input type='hidden' name='last_name' value='Jones' />
<input type='hidden' name='address1' value='address1' />
<input type='hidden' name='city' value='Manchester' />
<input type='hidden' name='zip' value='M20 1AA' />
<input type='hidden' name='country' value='UK' />
<input type='hidden' name='billing_first_name' value='Jack' />
<input type='hidden' name='billing_last_name' value='Jones' />
<input type='hidden' name='billing_address1' value='address1' />
<input type='hidden' name='billing_city' value='Manchester' />
<input type='hidden' name='billing_zip' value='M20 1AA' />
<input type='hidden' name='billing_country' value='UK' />
</form>
it is then been passed to an iframe which seems to work fine using:
<iframe width="100%" scrolling="no" height="580px" frameborder="no" name="hss_iframe" style="float:right;"></iframe>
<script type="text/javascript">
$(function(){
$("#PayPalForm").submit();
});
</script>
Can anyone help with why this data does not seem to pass anything through
--------------- EDIT
Changed cmd to _xclick and passes through fine, so obviously an issue with _hosted-payment
Can anyone give any ideas
If by "however, it does not seem to be passing through any of the variables", you mean it doesn't display the item name / item number: that's correct. Website Payments Pro Hosted Solution doesn't currently support item details. You should remove these parameters as they're not in use for this product.
In addition, the billing/shipping address will be used, but you won't be able to modify them if you're using templateD.

Categories