0

I'm using gravity forms on a page. When the form is validated the user arrives on a page with a payment form (Mollie).

Mollie has mandatory fields (first name, name...). Since I want to avoid users to retype those infos I'm passing these values via the URL and recuperate them in my template.

How can I now insert those values into the right fields ? I don't have access to the fields' code since it's generated by Mollie API.

Thanks in advance

Horratio
  • 27
  • 1
  • 7

2 Answers2

1

Answer the question

can use $_REQUEST to show value input

0

What you can do it's a GET request to the his page.

For example you create a form which will send to the next page something like that in the URL:

example.com?name=Fabio&age=30

So in your nextpage.php you can retrieve the data from url in that way:

<?php

$name = $_GET['name'];
$age = $_GET['age'];

Just a disclaimer: this isn't the most security and correct way to do it and isn't the "right" let's say. If you are sending some sensitive information please avoid or just simply don't use it.

You can do the same by using the POST method also with just the simply difference of:

<?php

$name = $_POST['name'];
$age = $_POST['age'];

But again, beware of sensitive information, you can make a clean of your inputs using some PHP functions as per the discussion here in the stackoverflow bellow:

How can I sanitize user input with PHP?

If you can avoid to do this hands on work preferrer to use a framework like:

https://laravel.com https://symfony.com

And some others you can research.

[EDIT]

As per @hùng nguyễn answered bellow, you can also use $_REQUEST global do retrieve this values.

And you can see all the values is on request trough:

<?php

print_r($_REQUEST);

[EDIT 2]

Thanks Fabio but how can I insert the values into the form fields ?

To insert the values into the form fields you can see the example as reference, using $_GET:

<form>
  <input value="<?=$_GET['name'];?>" name='name' id='name' type='text' />
  <input value="<?=$_GET['age'];?>" name='age' id='age' type='text' />
</form>

Example with $_POST:

<form>
  <input value="<?=$_POST['name'];?>" name='name' id='name' type='text' />
  <input value="<?=$_POST['age'];?>" name='age' id='age' type='text' />
</form>

I hope that helped you out.

  • Thanks Fabio but how can I insert the values into the form fields ? – Horratio Oct 14 '20 at 10:18
  • @Horratio I updated my answer adding a example, please upvote and marke as answer if helped you out to help anothers users too. – Fabio William Conceição Oct 14 '20 at 10:29
  • Thanks Fabio ! Almost there. Last question, I get a link to a file but the system is adding language in the url making it unusable. How can I remove ?lang=fr before displaying my URL ? Thanks – Horratio Oct 16 '20 at 06:06