在我的所有页面中,我都有一个文本按钮,如果单击它,它将在弹出的 div 中显示登录表单。如果用户重新加载页面,此弹出 div 将自动关闭。
现在我在 config.php 文件中有一个函数作为登录的配置。如果登录失败,那么在下面或登录表单的底部会有一个通知,说“登录失败”。
问题是因为这个登录表单只有在用户点击页面中的“登录”按钮时才会显示,所以当它重定向回来时它不会自动告诉用户他/她是否登录失败。用户必须再次点击登录按钮才能知道登录是否失败。
这是用户将知道登录是否失败的行:
<p><?php if($_GET['result']=='failed'){echo 'invalid login';}?></p>
这是登录框的完整代码,用户必须单击登录按钮才能显示登录表单的弹出 div:
<li>
<a href = "javascript:void(0)"
onclick ="document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block'">Login</a></li>
</ul>
<!--Black Overlay-->
<div id="fade" class="black_overlay" onLoad="initDynamicOptionLists()"></div>
<!--Pop Up Div-->
<div id="light" class="white_content">
<div id="loginbox">
<span id="login-form">Login</span>
<form method="post" action="config-login.php">
<table width="345" align="center" style="background:honeydew; vertical-align:top; margin:0px auto; border:solid medium yellowgreen;">
<tr>
<td class="myimage">Email :</td>
<td width="196" style="padding-right:2px;"><input type="text" name="member_email" style="width:100%"/></td></tr>
<tr>
<td class="myimage">Password : </td>
<td style="padding-right:2px;"><input type="password" name="member_password" style="width:100%"/></td></tr>
</table>
<div style="background:greenyellow; display:block; width:100%; overflow:hidden; margin:10px 0; padding:10px 0;">
<input type="hidden" name="return" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
<p><?php
if($_GET['result']=='failed'){
echo 'invalid login';
}?>
</p>
<input class="myimage" style="margin-right:10px; padding:0 10px; float:right;" type="submit" value="Login"/>
<span style="position: absolute; top: 11px; right:1px; color:white;" id="closeBlocked">
<a style="color:green; text-decoration:none; background:white; padding:10px;"
href = "javascript:void(0)"
onclick ="document.getElementById('light').style.display='none';
document.getElementById('fade').style.display='none'"><b>X</b></a></span>
</div>
</form>
</div>
</div>
<!-- End of Pop Up Div-->
<?php
session_start();
// include connection file
include("configPDO.php");
$member_email=$_POST['member_email'];
$member_password=$_POST['member_password'];
$return = mysql_real_escape_string($_POST['return']);
$STM = $dbh->prepare("SELECT * FROM customer WHERE member_email = :member_email AND member_password = :member_password");
$STM->bindParam(':member_email', $member_email);
$STM->bindParam(':member_password', $member_password);
$STM->execute();
$count = $STM->rowCount();
$row = $STM -> fetch(PDO::FETCH_ASSOC);
if ( $count == 1 ) {
session_start();
$_SESSION['login_id'] = $row['member_id'];
$_SESSION['member_name'] = $row['member_name']; // added
$_SESSION['member_email'] = $row['member_email']; // added
//echo 'SESSION =' .$_SESSION['myusername'];
//echo 'ROW =' .$row['myusername'];
//var_dump($row);
if ( $_SESSION['login_id'] != '' || $_SESSION['login_id'] > 0 ) { // edited
header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
} else {
header("location:index.php"."?result=failed");
}
}
else
{
header("location:index.php"."?result=failed");
}
$dbh = null;
?>
最佳答案
你可以在你的get变量的帮助下实现这个
只需将 id 添加到
<a href = "javascript:void(0)"
onclick ="document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block'">Login</a>
like
<a id="popmeup" href = "javascript:void(0)"
onclick ="document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block'">Login</a>
and put code at the end of document before end of body tag
<?php
if($_GET['result']=='failed'){ ?>
<script type="text/javascript">
document.getElementById('popmeup').click();
</script>
<?php }?>
关于php - 重定向回页面时保持弹出框显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26774143/
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我的代码目前看起来像这样numbers=[1,2,3,4,5]defpop_threepop=[]3.times{pop有没有办法在一行中完成pop_three方法中的内容?我基本上想做类似numbers.slice(0,3)的事情,但要删除切片中的数组项。嗯...嗯,我想我刚刚意识到我可以试试slice! 最佳答案 是numbers.pop(3)或者numbers.shift(3)如果你想要另一边。 关于ruby-多次弹出/移动ruby数组,我们在StackOverflow上找到一
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我想使用spawn(针对多个并发子进程)在Ruby中执行一个外部进程,并将标准输出或标准错误收集到一个字符串中,其方式类似于使用Python的子进程Popen.communicate()可以完成的操作。我尝试将:out/:err重定向到一个新的StringIO对象,但这会生成一个ArgumentError,并且临时重新定义$stdxxx会混淆子进程的输出。 最佳答案 如果你不喜欢popen,这是我的方法:r,w=IO.pipepid=Process.spawn(command,:out=>w,:err=>[:child,:out])
目前,Itembelongs_toCompany和has_manyItemVariants。我正在尝试使用嵌套的fields_for通过Item表单添加ItemVariant字段,但是使用:item_variants不显示该表单。只有当我使用单数时才会显示。我检查了我的关联,它们似乎是正确的,这可能与嵌套在公司下的项目有关,还是我遗漏了其他东西?提前致谢。注意:下面的代码片段中省略了不相关的代码。编辑:不知道这是否相关,但我正在使用CanCan进行身份验证。routes.rbresources:companiesdoresources:itemsenditem.rbclassItemi
如果我在模型中设置验证消息validates:name,:presence=>{:message=>'Thenamecantbeblank.'}我如何让该消息显示在闪光警报中,这是我迄今为止尝试过的方法defcreate@message=Message.new(params[:message])if@message.valid?ContactMailer.send_mail(@message).deliverredirect_to(root_path,:notice=>"Thanksforyourmessage,Iwillbeintouchsoon")elseflash[:error]
我刚刚按照thebootsygempage上的安装说明进行操作在我保存并查看帖子内容之前,一切看起来都不错。这是输出在View中的样子:HeaderSubhead:似乎没有呈现任何html格式,因为它被引号或类似的东西转义了-其他人有这个问题吗?我没有在github页面或SO上看到任何问题来指出我正确的方向。除了遵循gem安装说明之外,我还没有做任何事情,但也许我错过了什么或者只是犯了一个愚蠢的错误。如果你还有什么想知道的,请尽管问。干杯 最佳答案 你需要有这样的东西,转义html: 关