[英]PHP open another page in iframe POST data
I am creating an Phonegap app that submits user filled data from a form to my url at www.myDomain.com 我正在创建一个Phonegap应用,该应用将用户填写的数据从表单提交到我在www.myDomain.com上的网址
so the data sent will be using GET so the url possibilities are like this. 因此发送的数据将使用GET,因此url的可能性是这样的。
www.myDomain.com/processor.php?value1=99
www.myDomain.com/processor.php?value1=ninetyNine
I am opening these sites in an iframe. 我正在iframe中打开这些网站。
Now depending on the value and i can get more than 200 different types of values i want to redirect user to some website posting those values 现在根据值,我可以获得200多种不同类型的值,我想将用户重定向到一些发布这些值的网站
So i can redirect the above two examples like so 所以我可以像这样重定向上面的两个例子
www.numericProcessor.com //vlaue send by POST is 99
www.alphabeticProcessor.com //vlaue send by POST is ninetyNine
How do i Go about doing this? 我该如何去做?
Sounds like you're searching for a good design decision? 听起来您在寻找一个好的设计决策?
An easy solution could be to use a switch: 一个简单的解决方案是使用开关:
<?php
ob_start( );
$value = strip_tags($_GET['value1']);
if (!empty($value )) {
switch( strtolower($value) ) {
// add a case for each value you support (in lower case)
case "99": $url = "http://www.numericProcessor.com/"; break;
case "ninetynine": $url = "http://www.alphabeticProcessor.com/"; break;
default: $url = "/InvalidOption.html"; break;
}
header( "location: $url", true, 307 ); // not sure what status you'd prefer
exit;
}
?>
Might this be a good and easy way to do as you wanted? 可能这是您想要的一种简单便捷的方法吗? You can then navigate the iFrame to something like www.myDomain.com/processor.php?value1=99
然后,您可以将iFrame导航至www.myDomain.com/processor.php?value1=99
Please check the code before running, I haven't had the time to test it. 请在运行之前检查代码,我还没有时间对其进行测试。
EDIT: 编辑:
After our chat I think we solved the problem. 聊天之后,我认为我们已经解决了问题。 This untested piece of code might do the trick for you!
这段未经测试的代码可以为您解决问题!
<?php
$value = strip_tags($_GET['value1']);
if (!empty($value )) {
switch( strtolower($value) ) {
// add a case for each value you support (in lower case)
case "99": $url = "http://www.numericProcessor.com/"; break;
case "ninetynine": $url = "http://www.alphabeticProcessor.com/"; break;
default: $url = "/InvalidOption.html"; break;
}
print " <h1>Please wait while we refer you to the right website</h1>
<form method='post' action='$url'>
<input type='hidden' value='$value' name='<here the name they expact it>'>
</form>
<noscript>Please enable JavaScript, else we cannot refer you!</noscript>
<script language='JavaScript'>
document.forms[0].submit();
</script>";
}
}
Make sure to test first, as there are probably some dumb mistakes in it. 确保先进行测试,因为其中可能存在一些愚蠢的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.