下面的PHP应该确定是否存在?purpose=email
,然后如果存在则确定字符串是否包含?emailaddress
。如果有一个电子邮件地址,那么它会触发一组脚本,如果没有另一组。但无论如何,它的行为就像emailaddress !== '';
,知道为什么吗?
<?php if($_GET['purpose'] == 'email') {?>
<?php if($_GET['emailaddress'] !== '') {?>
<script type="text/javascript">
alert('<?php echo $_GET['emailaddress'];?>');
window.setTimeout(function(){
$('.dirops .loadpanel div span', window.parent.document).html('Complete');
$('.dirops .loadpanel', window.parent.document).removeClass('slideup');
},1000);
</script>
<?php } else { ?>
<script type="text/javascript">
window.setTimeout(function(){
$('.dirops .loadpanel div span', window.parent.document).html('Loading');
$('.dirops .confirmemail', window.parent.document).addClass('slideup');
},1000);
$('#confirmemail', window.parent.document).attr('href', 'http://www.golfbrowser.com/A4/directions.php?purpose=email&start=<?php echo $_GET['start'];?>&end=<?php echo $_GET['end'];?>')
</script>
<?php } ?>
<?php } ?>
任何想法?
的
尝试if($_GET['emailaddress'] != '')
,即!=
而不是!==
使用:array_key_exists('emailaddress', $_GET)
代替$_GET['emailaddress'] !== ''
if (isset($_GET['emailaddress'])) { ....
不知怎么的,我不认为if/else不起作用…
试试var_dump($_GET)
,也许isset($_GET['emailaddress'])
能帮到你。
试着改变前两行:
<?php if(array_key_exists('purpose', $_GET) && $_GET['purpose'] == 'email') {?>
<?php if(array_key_exsist('emailaddress', $_GET) && $_GET['emailaddress'] != '') {?>