search

Home  >  Q&A  >  body text

PHP obtain form value problem

<input type="text" name="keyword" value ="<?php  echo $_POST['keyword'] ;?>"  required="required">

The code is as shown above

After entering the value in the save form, I use $_Post to get the value, and then output it in value


But when opening the web page, the value is empty, $_POST cannot get anything, and an error will be reported

How to solve it

再见理想再见理想2155 days ago1543

reply all(6)I'll reply

  • phpcn_u146783

    phpcn_u1467832019-02-18 21:57:54

    can be changed to this

    <?php echo $_POST['keyword'] ?? '';?>


    reply
    0
  • 天幕流光_-

    天幕流光_-2019-02-18 12:03:44

    Declare a variable assignment in the php code and then output it; or use a function to judge (isset)

    reply
    0
  • 天幕流光_-

    天幕流光_-2019-02-18 12:01:08

    You are mainly reporting an error because the keyword does not exist

    reply
    0
  • 天幕流光_-

    天幕流光_-2019-02-18 11:59:52

    $_POST is used to receive the data submitted by the form. If it is not submitted or the key value does not exist, an error will be reported

    reply
    1
  • jjJ

    jjJ2019-02-17 09:56:40

    Are you sure you passed the value?

    reply
    0
  • Cancelreply