dsf11t5u1651 2017-02-28 19:14
浏览 21
已采纳

返回false后重定向用户

I have some validation fields like this :

if (empty($_POST['finalidade_imob']) || $finalidade_imob == "Escolha 1" || 
        !in_array($_POST['finalidade_imob'], $fi_options)) {    
    $finalidade_imob = "Escolha 1";
    $error++;
} else {
    $finalidade_imob = $_POST['finalidade_imob'];
}

//on the end
if ($error !== 0) {
    return false;
}

But the location of my form is on bottom of my page, so when return false is called the page is reloaded on the top.

If i put this:

if ($error !== 0) {
    header('location:perfil.php#content_cadastro_completo');    
    return false;
}

This page is reloaded for exactly to the place i need, but return false dont work... I know why return dont work, i put that for explain what i need...

So what i need do to goal this target?

Sorry my bad english...

Edit Without js... Only PHP.

  • 写回答

1条回答 默认 最新

  • doudian7996 2017-02-28 20:14
    关注

    My question no clear for this solution, but in my all context this work.

    The solution that I found is put placeholder in my action.

    action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>#content_cadastro_c‌​ompleto"

    and

    if($error !== 0)
    {   return false;//no need header() to go to the placeholder...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64