I know I can send a custom field using IPN with $_POST['custom']
But can I do that with an uploaded file? More specifically an uploaded image?
And what if I have two custom fields? I previously used something like this:
<input type="hidden" name="custom" value="<?php echo $a.'|'.$b ?>"/>
But that was just text! Now I want to upload a file and I also have custom text, then I want to get it.
Is this possible and how would that look like?
Thanks!
I don't think it's possible to do it the way you're describing, but here's an alternative that I have used in the past.
Instead of having the form that contains the file upload post to PayPal, have it post to your site, and then store that uploaded file and any other custom data in a database (or any other way you choose to store it). Assign that data an id.
Now redirect the user to a page that contains basically the same form, except that the input fields should be hidden, and the form will post to PayPal. Fill in that form programmatically with the data from the previous post, and fill the 'custom' field with the id that you assigned to the custom data. This page would also contain a JavaScript statement like this (at the bottom after the form, to ensure that it doesn't execute until the form is loaded)...
<script type="text/javascript">
document.forms["paypalform"].submit();
</script>
...to automatically submit the form when the page is loaded. It's still a good idea to leave a submit button (you could style it as a link, if you want) in case the user has JavaScript disabled. It could say something like "Click here if you are not redirected to PayPal within 10 seconds." You could also add another message on the page such as "Redirecting to PayPal."
Now when you get your PDT or IPN information back from PayPal for that transaction, the 'custom' field will contain the id you assigned to the data earlier. It's just a matter of retrieving the data from wherever you stored it.
I've done this in ASP.NET before, and I assume it would work just as well in PHP (the server-side parts), but I can't say for sure.
Note: The 'custom' field can only contain up to 256 characters.
Related
I'm doing a form where when you select an option (with the and tag), a text below the form change according to the choice.
I would like to have this text along with my form data when send to a POST request.
I'm using Express and EJS.
Btw I also have GET parameters and would like the same thing as the text, any thoughts ?
Can you help me please ?
Thanks !
Whatever code you have that changes the text according to your choice, can also set a hidden form value in your form to the same value. That hidden form value will not display to the end user in the browser, but will be sent with the form as part of the POST (as another value of the form).
Here's an example of a hidden form element from that previous linked reference:
<input type="hidden" id="custId" name="custId" value="3487">
If this is inside your <form>, you can then change it with your Javascript to whatever you want it to and it will be automatically sent to your server as one of your form values when the form is POSTed to your server, but won't be shown to the user because of the type="hidden".
I'm currently testing a landing page made with amp.
There's a lot of information on how to make forms but,
nothing on how the form is process.
Where we insert the recipient email?
Do we need to make a submiter.php?
Thank you!
Yes, you need to create a server endpoint to handle the form submission. If you use method="POST" then you should also add action-xhr="submitter.php" and then submitter.php should collect the values in the form, and return JSON to the AMP page.
If you use method="GET" then you can use action="submitter.php" or action-xhr="submitter.php. If you use action and not action-xhr then submitter.php doesn't need to return JSON, it can just be a normal PHP/AMP page that takes the values of the form and sends an email or whatever you want
I set up a PayPal form with hidden fields in order to collect user information on PayPal and cross-reference what users had paid for a specific item.
After the most recent updates, the shortcodes I used stopped working within the form.
Now the information saved is actually the text of the shortcode, not the output of the shortcode information.
An example of the form code looks like this:
<input name="os0" value="[wpv-current-user]">
This used to collect the username, but since the update, the information it collects is the text "[wpv-current-user]" even though, when outside the form, the shortcode works just fine and will display the username.
Any suggestions?
I have a page called contact.htm with a working form. One of the checkbox fields on the form is named Garden (so either it is checked or not when using the form).
I have another page that I want to link to my form page, so that if a user clicks a particular link, they are sent to the form page and the field Garden is pre-clicked.
I have not been able to do this though I have tried several methods...such as:
a href="contact.htm?checkbox=Garden,on" or
a href="contact.htm?checkbox=Garden,checked" or
a href="contact.htm?input type="checkbox" name="Garden" value="checked", and some others.
I would appreciate any help.
You'll need to use JavaScript on the target webpage to process the argument and fill the values in. There is no automatic way of doing this just by URL.
This link shows how to retrieve URL arguments from JavaScript. From there, it's a matter of using standard JavaScript or JQuery to fill the values in.
I'm creating a form where the user will enter data, then click "Review" to see the data they entered. Then after review, "Save" the record.
I'm using a <cfform> to submit the form but wonder how to submit the data to the database from the "Review" page since there's no form here.
Should I set variables like FORM.Name = VARIABLES.Name to display on the review page, then convert them back after they submit the "Save"?
Not really sure what to do here. Overthinking?
Just keep in form scope. Basic output of form values, using baked in form.fieldList:
<cfloop list="#form.fieldList#" item="fieldName">
<cfoutput>
#fieldName#: #form[fieldName]#<br>
<input type="hidden" name="#fieldName#" value="#form[fieldName]#">
</cfoutput>
</cfloop>
Link to original form or submit to page where you save it, using values from hidden fields (which should mirror original form values)
A few other ways you could do this, but this seems simplest to me.
Why not using a second form with hidden input fields for the review page? Confirm would be a submit button to the page that saves the data to the server.
Second possibility (not that proper): save the data directly into the database and load it for the review from there. Trick: use a flag with "confirmed" and set it if confirmed. Bad part about that: you have to clean up older data that has not been confirmed.
Improving on Billy Cravens answer. This protects against the fields having Embedded Attacks
<cfoutput>
#lcase(fieldName)#: #xmlFormat(form[fieldName])#<br>
<input type="hidden" name="#fieldName#" value="#xmlFormat(form[fieldName])#" />
</cfoutput>
Also this will not work for image uploads. The lcase(fieldName) is to keeps the fields from being displayed as all caps. Lowercase is often easier to read.