I'm creating a custom PayPal "Pay Now" button based on the results of the creation of a CCK node. Basically, someone is creating their own "registration" for an event and then are redirected to a "pay now" page which is of the "PHP" input type. When I do a "print_r($_POST)", the variable is empty.
How can I use the data just stored in the new node? Or, at least use PHP to inspect the POST parameters given to create the node? I'm trying to populate a "Pay Now" button for PayPal.
(disclaimer that I have some odd requirements as to how payment is handled/directed, otherwise I would use an existing module like UberCart)
Note that I've turned off users ability to view nodes that they've just created as it contains personal information.
Well, the main question here is how you do the redirection after node submission. After completing a form submit cycle, the user normally gets redirected to whatever ends up in the forms '#redirect' entry. One effect of this redirect is that the POST data will be gone on the target page.
So in order to get access to the created node on the target page, you'll probably have to pass it the nid of the created node, e.g. by adding it to the redirect URL (potential security issue) or storing it in the session data in the node creation forms submit function. Then you can just do a node_load() on the target page, using the passed nid.
Related
I have a web page that loads all the data from a mysql database called datalist.php
From this page I can edit record by record with a button that redirects you to an editdata.php page adapted to the fid of the record.
Once edited as they want to see the changes, I don't redirect them to the main one letting them see the changes and simply clicking back or with a button they return to the datalist.php without any problem.
The button is this
echo "<p id='parrafo'><a style='padding:1px 20px'class='button rounded-0 primary-bg text-white w-0 btn_1 boxed-btn' href='javascript:history.back() '><--</a></p>";
PROBLEM
I added a search engine where the displayed data can be filtered.
When they use the search engine from datalist.php, I direct them to a page called search engine.php where, through a post method, I store what they are looking for in a variable and the data that users want appears.
But when they edit a filtered record, it is edited without problems, but when they go back, they return to the search engine.php and the message appears:
"Confirm form resubmission In order to display correctly, this web page needs the data you entered earlier. You can submit that data again, but that will cause the page to repeat all previous actions. Press Reload to submit the data and display the page.
Hit the page refresh button to resubmit the data needed to load the page."
Of course, if they update, they come back when the filtered data comes out.
Isn't there any way to store the variable used in the search so that when I go back I don't get this error or any solution??
simple! when user will submit form for that variable instead of making post request
option1: just use get request __url__?variable=... but this will not remember the variable when you go back
option2: store the variable in the cookie and just go to next page (eg. window.location.href = '...';). and in next page access the cookie from php.
If you are wanting to show the form to the user as a confirmation, but without the possibility of another post, then remove the form element and the button. Display all other boxes as they are (with the values populated from the POST array).
And display another message telling them that it has been successful.
You are using PHP, you can achieve this easily with it. If you are unsure, then post a short version of your code in a separate question.
I have a HubSpot form embedded into a WordPress page.
What I'm trying to achieve is gated and ungated content. See these use cases as an explanation:
User enters WordPress page for the first time on content that is gated by default (by gated
I mean it shows a form).
User fills out the form and gets redirected to whatever is specified as the redirect
option in HubSpot (the content is now ungated).
User closes the window but decided to back onto the WordPress page. Now, since the
user has already filled out the form (the cookie for hubspotutk
exists), I want the user to be redirected straight to the asset
(whatever is specified in the redirect option in HubSpot forms).
How far have I got?
I've created an ACF field in WordPress with radio buttons for Gated or ungated content. By default, all content is ungated.
I've then set a cookie based on this ACF field value. I.e. if the content is gated, resourceType cookie equals "Gated".
That's how far I have got.
The next steps (I think) would be to...
Only "ungate" the page if the user has filled out that form. For example, I've completed a form, the hubspotutk cookie value is "23a43a4a6de9c38f7657ebd08d574scf". How does HubSpot know which form this value is assigned to?
Other concerns:
If the user has filled out the form already, how to I redirect them straight to the asset? Is there a way to get the "redirect to another page" value in the image below as a variable?
I don't want to use HubSpot Forms API because I don't expect the admin to create the forms via the API. They'll want to create it via the HubSpot forms option.
Any ideas?
I need store different post data to each tab in a browser. If I open a new instance of the same page, the data aren't shared between both.
My problem:
I'm building a CMS to control my website content. But I will open some instances of the same page (many tabs). So I have a search form to find news that I been created on my CMS. If I open a news item I have a cancel button that back to previous page (the news list).
The problem is that the news list have a pagination and a filter form. So I can, for instance, search by a term like "john doe" and advance to page 5, and open a news item. If I cancel, currently I back to news list without filter and on first page.
My solutions:
Well, I don't want to use the history.back() because I can submit a news form and click on back/cancel button. So, I'll back to the current form, what is wrong.
My second idea is to store a $_SESSION with the $_POST sent to the news list and the back button send me to /news/list/recovery-session, that will recovery the $_POST data from session. But it have a problem: if I open two tabs and make two searchs, I'll have only the last session saved.
Your solutions:
Well, I can work with PHP and JS to make it work. You can suggest a idea of what I can do. I think about work with COOKIES, but I belive that it is shared by domain, and not by tab, what is a problem.
Someone?
Generate a unique id and attach it to the form or some hidden element that will be submitted. Save that unique id in a cookie or session variable. Compare the two at time of submission.
If second tab has generated a new id, the first tab will not evaluate to true.
The main problem is the need to persist the state of what page to return to and also the search term when returning back to the news list page. There are many ways to accomplish this, but one simple method is by encoding this data into your query string.
As an example, assuming your search term is "john doe" and you are on page 5, pass that data along to your news page.
news.php?returnSearchTerm=john+doe&returnPage=5& ....
When the news page is created, you can format your cancel link to send you back to the list page with the correct parameters.
news_list.php?search=john+doe&page=5
I am creating a site that requires a user to add tags to their forum. I have already implemented the form and button to add tags to an array, but I am wondering if there is a way in which:
when a user clicks on the "add tag" button again, it will add the new tag to the array even when the page refreshes...
you'll probably want to use a database for what you're trying to do. An array in a php script is short-lived, it only exists for the duration of that single request.
Lets say I have a Page with a List (list.php).
I click on a row on that list to Edit that record. I go to a edit.php Page.
I have 3 buttons on that edit.php page. Save, Apply, Cancel
Save button - Saves the Record and returns to the (list.php) Page
Apply button - Saves Record but stays on the same page (edit.php)
Cancel button - No save, just return to the (list.php) Page
But now image if I can access for edit that item on a different page. How do I return to that calling page?
Do I add a parameter(code) to the URL? something like a Page Origination Code?
Do I save the previous page URL in a session? (bad, they can right click open another page and that would be saved to session url)
Am just curious to how others return to a previous page after a SAVE.
you can the server variable $_SERVER['HTTP_referrer'].
They are other ways also you can store in session the current page and use is processing page.
Adding a parameter to the URL is the only reliable though quote ugly way.
That's why such an in-place editions nowadays often being implemented using AJAX, and this very site is a perfect example.
However, there are different cases.
Login page is imperfect example for example, as you always have a form instead of just a link, and thus you can always store the current page in a hidden form field.
Another approach is possible if you are using some sort of front controller, and all requests actually being directed to the single index.php file which runs appropriate script based on the URI.
in this latter case you will need no more than mere a redirect to the current page.