<script> document.location.href='';</script> & 转


<script> document.location.href='';</script> & Go to page related questions

<? echo "<script> document.location.href='main.php';</script>"; ?>

此代码运行良好

但是,从表单页发送值

<form action="smssend.php" method="post" id="quickform"> 
<input type="hidden" name="returnUrl" value="<? =PHP_SELF?>"> 

这为下一页提供了一个值

<? echo "<script> document.location.href='$_POST[returnUrl]';</script>"; ?>

如果源和页面不会移动,则会发生运行时错误。

我错了吗?

在表单页面下,我收到了来自电话号码的消息,参考页面源来处理较少。

<?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>"; ?>
<? echo "<script> document.location.href="$_POST[returnUrl]";</script>"; ?>

您的问题在于字符串分隔符

尝试使用<html></html>标签。

<? echo "<html><script> alert('Done');</script></html>"; ?>

<? echo "<html><script> document.location.href='$_POST[returnUrl]';</script></html>"; ?>

我的猜测是

<input type="hidden" name="returnUrl" value="<? =PHP_SELF?>"> 

实际上应该是

<input type="hidden" name="returnUrl" value="<?=PHP_SELF?>"> 

查看表单的源代码,并确保隐藏输入的值具有正确的值。