0

Please forget my bad English.

I created a simple application using the GD library, but on form must inform the text from the image, the padding x and y padding, that will be received in DG variables in PHP: $ title, $ x and $ y.

In file form.php I have a simple form:

  <form method = "POST">
   Title <input type = "text">
    X <input type = "text">
    Y <input type = "text">
   / * Others fields * /
</ form>

I do not know how to create a json with the data from the form, and then I continue in php:

$ json = json_decode ($ jsondata, true);
1
  • json_encode($_POST) Commented Dec 5, 2015 at 14:39

1 Answer 1

1

Here is tiny code snipped that allows you to do that:

<form method = "POST">
    Title <input name="title" type = "text">
    X <input name="x" type = "text">
    Y <input name="y" type = "text">
    <!-- other fields -->
    <input type="submit" value="Submit">
</form>


<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $json = json_encode($_POST);

    echo $json;
}
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.