doulu1914 2019-02-02 16:16
浏览 69

使用ISSET(),Html Select Option代码的值永远不会为假

I am trying to better understand the ISSET() function. It is my understanding that when used properly, I can determine if a "submit" button was pressed or not because the function determines true or false. I have written some html code that uses the HTML Tag and HTML tag type submit. What I was trying to test was whether the ISSET function would return False while the button was not pressed and True when it was pressed.

Using Wordpress Plugin called "Woody snippets" it allows the combination of HTML and PHP in a shortcode.

Please see my code below:

I have been trying to follow a validation video on youtube = https://youtu.be/x_-HdHijmkw

I did everything line for line and initially it worked, upon refreshing the page, it did not clear all of the variables and the isset function acted as if the boolean was true. I thought it was my cache, so I cleared it. Still the ISSET funtion acts as if the boolean is true.

<?php
if (isset($_GET['fname']) && isset($_GET['lname'])) {
$fname = $_GET['fname'];
$lname = $_GET['lname'];
echo "Hello ".$fname;
}
?>

<form action='' method='get'>
First Name: <input type="text" name="fname"><br>
Last Name: <input type="text" name="lname"><br>
<input type="submit" value="Greet Me"><br>
</form>  

I expected upon refresh that the isset() function and the variables used to determine true or false would be false until I entered values and pressed the button again.

  • 写回答

2条回答 默认 最新

  • dongmeng1868 2019-02-02 16:23
    关注

    Pre info: isset($a) && isset($b) is equivalent to isset($a,$b)

    isset() proofs the existence of a var, not if it is empty. Try

    if ( isset($_GET['fname'],$_GET['lname']) 
        && strlen($_GET['fname']) 
        && strlen($_GET['lname'])  { ...
    
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号