我有一个网站。如果有人发布查询,它会转到感谢页面 www.legasy.com/thankyou/URL 将是这样的。当我分析网站管理员工具时,它显示的感谢比询问更多。
填写表单字段后验证并将该值插入表中。它将转到感谢页面。但是,如果有人键入 url,则它不应转至感谢页面。我能为此做什么?
下面是我的代码
HTML
<form>
<table>
<tr><td>Name</td>
<td><input type="text" name="buyer_name" id="buyer_name" size="31" value="" /></td>
</tr>
<tr> <td>Email</td>
<td><input type="text" name="buyer_email" id="buyer_email" size="31" value="" /></td>
</tr>
<tr> <td>Contact No</td>
<td> <input type="text" name="buyer_mobile" id="buyer_mobile" size="31" value=""/></td>
</tr>
<tr>
<td colspan="2" style="text-align:center;">
<div id="post_enquiry"><img src="./images/for_more_det_click.gif" onclick="postBuyerEnquiry();" style="cursor:pointer;"/></div>
</td>
</tr>
</table>
</form>
Javascript
<script type="text/javascript" src="../scripts/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
function postBuyerEnquiry()
{
var nametxt = document.getElementById('buyer_name').value;
var emailtxt = document.getElementById('buyer_email').value;
var phonetxt = document.getElementById('buyer_mobile').value;
output ="text";
if(nametxt=='')
{
alert("Please Enter Your Name");
return false;
}
else if(emailtxt=='')
{
alert("Please Enter Your Mail Id");
return false;
}
else if(phonetxt=='')
{
alert("Please Enter Phone Number");
return false;
}
process = 'loadEvent';
output = 'text';
url = "test4.php";
$.get(
url,
{'act':'SBQF',
'name':nametxt,
'email':emailtxt,
'phone':phonetxt,
},
function(responseText)
{
window.location.href = '/legasy.com/thankyou/';
},
"html"
);
}
PHP
<?php
if ( !empty($_POST['act']) )
{
$act = formatstring($_POST['act']);
}
switch( $act )
{
case "SBQF":
$strName = $_GET['name'];
$strEmail = $_GET['email'];
$strPhone = $_GET['phone'];
//Inserting values into the database
exit;
break;
}
?>
或
如果有人输入 URL (www.legasy.com/thankyou/) 它想转到错误页面
最佳答案
elseelse { // Give this here
process = 'loadEvent';
output = 'text';
url = "test4.php";
$.get(
url,
{'act':'SBQF',
'name':nametxt,
'email':emailtxt,
'phone':phonetxt,
},
function(responseText)
{
window.location.href = '/legasy.com/thankyou/';
},
"html"
);
return false;
}
在任何时候,这都会被执行。另外,在 else 部分的末尾也给出 return false;!
如果不希望用户直接访问www.legasy.com/thankyou/页面,可以设置一个session。在你做成功的那一刻,你可以这样设置一个 session 。
session_start();
if (condition on success)
$_SESSION["thankyou"] = true;
在 www.legasy.com/thankyou/ 页面中,
session_start();
if (!isset($_SESSION["thankyou"]) && $_SESSION["thankyou"] != true)
{
header('Location: /error/');
die();
}
关于php - "Thank you"当有人输入 URL 时页面不应该显示,你会怎么做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13926169/
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
从给定URL下载文件并立即将其上传到AmazonS3的更直接的方法是什么(+将有关文件的一些信息保存到数据库中,例如名称、大小等)?现在,我既不使用Paperclip,也不使用Carrierwave。谢谢 最佳答案 简单明了:require'open-uri'require's3'amazon=S3::Service.new(access_key_id:'KEY',secret_access_key:'KEY')bucket=amazon.buckets.find('image_storage')url='http://www.ex
我正在编写一个小脚本来定位aws存储桶中的特定文件,并创建一个临时验证的url以发送给同事。(理想情况下,这将创建类似于在控制台上右键单击存储桶中的文件并复制链接地址的结果)。我研究过回形针,它似乎不符合这个标准,但我可能只是不知道它的全部功能。我尝试了以下方法:defauthenticated_url(file_name,bucket)AWS::S3::S3Object.url_for(file_name,bucket,:secure=>true,:expires=>20*60)end产生这种类型的结果:...-1.amazonaws.com/file_path/file.zip.A
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
我正在阅读SandiMetz的POODR,并且遇到了一个我不太了解的编码原则。这是代码:classBicycleattr_reader:size,:chain,:tire_sizedefinitialize(args={})@size=args[:size]||1@chain=args[:chain]||2@tire_size=args[:tire_size]||3post_initialize(args)endendclassMountainBike此代码将为其各自的属性输出1,2,3,4,5。我不明白的是查找方法。当一辆山地自行车被实例化时,因为它没有自己的initialize方法
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub