doutui8842 2013-03-21 23:49
浏览 26
已采纳

Colorbox不执行PHP代码

there is a problem that's driving me nuts for hours:

I have a php-file and want it load in a colorbox modal-popup via AJAX but the php-code inside of the file doesn't get executed (normal HTML-tags like divs are visible only if I remove all PHP stuff). I have no idea why this is happening.

I can see e.g. the constants' names (like EP_AVATAR_RESTRICTIONS) but not their content (in this case it's just text).

Please - if anyone can help me out in this situation I'd really really appreciate it. TIA!

My colorbox code:

$(".edit_avatar_link").colorbox({
        initialWidth:'386',
        initialHeight:'528',
        innerWidth:'386',
        innerHeight:'528',
        href: "<?php echo $setting['site_url'];?>/includes/forms/avatar_form2.php",
        fixed:true,
        scrolling:false,
        transition:'none',

        onComplete: function(){
            $("#cboxLoadedContent").appendTo("#cboxContent");

            var title = 'Edit Avatar';
            $('#cboxTitle').text(title);
        }
    });

My PHP-file (avatar_form2.php):

<?php defined( 'AVARCADE_' ) or die( '' ); // Security ?>
<div id="edit_avatar_content">
<div class="edit_profile_header"><?php echo EP_EDIT_AVATAR;?></div>
<div class="edit_avatar_container">
    <div class="edit_profile_lable"><img src="<?php echo $user['avatar'];?>" width="75" height="75"></div>
    <div class="edit_avatar_element">
        <form enctype="multipart/form-data" id="form1" method="post" action="?task=edit_profile&done=avatar">
            <input name="new_id" type="hidden" id="new_id" value="<?php echo $new_id;?>" />
            <span class="style1"><?php echo EP_AVATAR_UP;?></span>
            <input name="img_file" type="file" id="img_file" size="50" /> <input type="Submit" name="Submit" value="<?php echo EP_AVATAR_BUTTON;?>"/>
            <?php echo EP_AVATAR_RESTRICTIONS;?>
        </form>
    </div>
</div>

  • 写回答

1条回答 默认 最新

  • dongtu1958 2013-03-22 00:12
    关注

    It is normal that you don't get anything. Your colorbox calls a programatically protected php file.

    This line of code is causing it:

    <?php defined( 'AVARCADE_' ) or die( '' ); // Security ?>
    

    This is a direct access protection so that you can not directly access this file. One makes that to only make it includable from other php files that do a DEFINE('AVARCADE_','something');

    either remove that line of code or make another php file that defines the AVARCADE_ constant and then include the vatar_form2.php in that file

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示