php <script> document.location.href='';</script> & 转到页面相关问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19897764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
<script> document.location.href='';</script> & Go to page related questions
提问by bismute
<? echo "<script> document.location.href='main.php';</script>"; ?>
This code is running well
这段代码运行良好
But, sending values ??from the form page
但是,从表单页面发送值
<form action="smssend.php" method="post" id="quickform">
<input type="hidden" name="returnUrl" value="<? =PHP_SELF?>">
This gives a value to the next page
这为下一页提供了一个值
<? echo "<script> document.location.href='$_POST[returnUrl]';</script>"; ?>
Run time error occurs if the source and the page will not move.
如果源和页面不会移动,则会发生运行时错误。
Does what I'm wrong?
我错了吗?
Under the form page I received the message from the phone number with reference to the page source to handle less.
在表单页面下我收到的短信联系电话号码参考页面源码来处理的少。
<?php
$config['SMS_ID']="test";
$config['SMS_PW']="test1234";
$config['cf_tel']='01234567';
$post_data = array(
"remote_id" => $config['SMS_ID'],
"remote_pass" => $config['SMS_PW'],
"remote_num" => 1,
"remote_reserve" => 0,
"remote_phone" => $_POST[number],
"remote_callback" => $config['cf_tel'],
"remote_msg" => $_POST[counsle]
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.mymunja.co.kr/Remote/RemoteSms.html" );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$msg = curl_exec($ch);
curl_close($ch);
?>
<? echo "<script> alert('Done');</script>"; ?>
<? echo "<script> document.location.href='$_POST[returnUrl]';</script>"; ?>
回答by tdjprog
<? echo "<script> document.location.href="$_POST[returnUrl]";</script>"; ?>
your problem is with string delimiters
你的问题是字符串分隔符
回答by Bar?? ERTU?RUL
Try use <html></html>
tag.
尝试使用<html></html>
标签。
<? echo "<html><script> alert('Done');</script></html>"; ?>
<? echo "<html><script> document.location.href='$_POST[returnUrl]';</script></html>"; ?>
回答by Tad M.
My guess is
我的猜测是
<input type="hidden" name="returnUrl" value="<? =PHP_SELF?>">
should actually be
实际上应该是
<input type="hidden" name="returnUrl" value="<?=PHP_SELF?>">
View source of your form and make sure the value of your hidden input has the correct value.
查看表单的源代码并确保隐藏输入的值具有正确的值。