duanbiyi7319 2017-04-04 23:03 采纳率: 100%
浏览 68
已采纳

PHP查询字符串不返回$ _GET的全文

Currently I have an html form where users can enter an address string.

For example, if they enter "74 Egan Drive" in the text box, it will take them to the following URL:

http://example.com/Edit_Address.php?address=74+Egan+Drive

I am trying to use PHP to grab the address and put it inside a form with $_GET['address'], such as:

Echo "<label>Street Address</label><input name=\"address\" type=\"text\" value= ".$_GET['address']."><br>";

But inside the text box, only the number 74 shows up, and not the full address.

What am I doing wrong here?

  • 写回答

2条回答 默认 最新

  • dsf4s5787 2017-04-04 23:05
    关注

    You forgot the quotes around your HTML value attribute resulting in only the content before the first space being displayed and the rest being ignored as useless HTML attributes.

    echo '<label>Street Address</label><input name="address" type="text" value= "'.$_GET['address'].'"><br>';
    

    FYI, I changed the way you used quotes to make this easier to read.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?