此代码正在尝试验证是否已将链接输入到浏览器中,但是,Please enter the URL to clone
即使不需要,警告消息仍会显示在页面顶部。任何人都可以提出一种不出现的方法吗?我在下面附上了我的代码。
$posted_radio = (isset($_POST['git']) ? $_POST['git'] : null);
$posted_url = (isset($_POST['clone-url']) ? $_POST['clone-url'] : null);
if($posted_radio == "pull"){
echo "This would cause a git pull";
}
if (!empty($posted_url)){
echo "<p>This would post: </p><code>git clone"." ".$posted_url."</code>";
}else{
echo "Please enter a URL to clone";
}
?>
<form method="POST" action="index.php">
<input type="radio" name="git" value="clone" id="clone"><label>Clone</label><br>
<label class="clone-url">Clone URL:</label><input type="url" name="clone-url" class="clone-url"><br>
<input type="radio" name="git" value="pull"><label>Git Pull</label><br>
<button class="btn btn-primary">Submit</button>
</form>