M
M
MadHowradBot2021-07-26 17:24:44
PHP
MadHowradBot, 2021-07-26 17:24:44

How to put data from input into php variable?

How to put data from input into php variable?
I have a form like this:

<body>
  <div class="limiter">
    <div class="container-login100">
      <div class="wrap-login100">
        <div class="login100-pic js-tilt" data-tilt>
          <img src="images/img-01.png" alt="IMG">
        </div>

        <form class="login100-form validate-form" method="POST">
          <span class="login100-form-title">
            Say
          </span>

          <div class="wrap-input100 validate-input" data-validate = "ID required">
            <input class="input100" type="text" placeholder="Id" name="ID">
            <span class="focus-input100"></span>
            <span class="symbol-input100">
              <i class="fa fa-envelope" aria-hidden="true"></i>
            </span>
          </div>

          <div class="wrap-input100 validate-input" data-validate = "Mesage required">
            <input class="input100" type="text" placeholder="Message" name="msg">
            <span class="focus-input100"></span>
            <span class="symbol-input100">
              <i class="fa fa-lock" aria-hidden="true"></i>
            </span>
          </div>
          
          <div class="container-login100-form-btn">
            <button class="login100-form-btn">
              Login
            </button>
          </div>

          <div class="text-center p-t-12">
            <span class="txt1">
              Forgot
            </span>
            <a class="txt2" href="#">
              Username / Password?
            </a>
          </div>

          <div class="text-center p-t-136">
            <a class="txt2" href="#">
              Create your Account
              <i class="fa fa-long-arrow-right m-l-5" aria-hidden="true"></i>
            </a>
          </div>
        </form>
      </div>
    </div>
  </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Danchenko, 2021-07-26
@MadHowradBot

After the POST request is completed, all data will be stored in the $_POST global variable. They will be available in this form (if they were sent):

array(2) {
  ["id"]=>
  string(1) "1"
  ["msg"]=>
  string(18) "Сообщение"
}

Then we can get them:
// Если данные не были получены, переменные будут содержать значение null.
$id = $_POST['id'] ?? null;
$msg = $_POST['msg'] ?? null;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question