我从html调用PHP函数,我想确保当相应的输入框为空时会发生一件事,而其他事情则没有。 由于某种原因,PHP认为它总是不为空。无法弄清楚原因。
html片段:
<input type="button"
value="checkout"
onClick="self.location='testphp.php?checkout=true&folderName=\'' + document.folderForm.folderLocation.value + '\''">
</button>
<form enctype="multipart/form-data" method="post" name="folderForm">
<input type=file name="myfile">
<input type=text name="folderLocation" id="folderLocation">
<input type=hidden name="folderName">
<input type=button value="Get Folder" onclick="javascript:GetFolder();">
<input type=hidden name=submitted value=1>
<input type="submit" value="Create Repository" />
</form>
php片段:
if($_GET['checkout']){
if( isset( $_GET['folderName'] ) && !empty( $_GET['folderName'] ) ) {
echo $_GET["folderName"];
echo exec("/var/www/html/checkout.sh ".$_GET["folderName"]);
} else {
echo "<script type='text/javascript'>alert('Please choose repository from the list first');</script>";
}
}
任何想法?
答案 0 :(得分:0)
尝试将!isempty( $_GET['folderName'] )
更改为strlen( $_GET['folderName'] ) > 0
。
编辑在这种情况下,问题是由'
参数中的folderName
引起的,其中folderName
为空,结果为$_GET
仍然包含两个引号。