dsfb20227 2013-02-13 04:34 采纳率: 0%
浏览 36
已采纳

echo javascript表单值[重复]

This question already has an answer here:

I have this script.

<head>
<script type="text/javascript" src="sha1.js"></script>

</head>
<body>
<?php
$A= 'TEST01';
$B= '059B8125F';
$C= '20061123_003';
$D= '100.00';
$E= '50126';

?>
<form name="checkout" method="post" action="">
<input type="hidden" name="A" value="<?php echo $A; ?>" />
<input type="hidden" name="B" value="<?php echo $B; ?>" />
<input type="hidden" name="C" value="<?php echo $C; ?>" />
<input type="hidden" name="D" value="<?php echo $D; ?>" />
<input type="hidden" name="E" value="<?php echo $E; ?>" />
</form>

<script type="text/javascript" language="javascript">
var str = "##" + form.A.value.toUpperCase() + "##" + form.B.value.toUpperCase() + "##" + form.C.value.toUpperCase() + "##" + form.D.value.toUpperCase() + "##" + form.E.value.toUpperCase() + "##";

form.SIGNATURE.value = hex_sha1(str);
</script>


</body>

My question is, how to show the SIGNATURE value ini PHP? I want to show it in echo. Is it possible?

Thank you all

</div>
  • 写回答

1条回答 默认 最新

  • douhui0975 2013-02-13 04:59
    关注

    PHP's sha1 function may be useable for this.

    This should be calculate from php-side.

    <head>
    <script type="text/javascript" src="sha1.js"></script>
    
    </head>
    <body>
    <?php
    $A= 'TEST01';
    $B= '059B8125F';
    $C= '20061123_003';
    $D= '100.00';
    $E= '50126';
    
    $hash_str = "##" + strtoupper($A) + "##" + strtoupper($B) + "##" + strtoupper($C) + "##" + strtoupper($D) + "##" + strtoupper($E) + "##";
    
    $signature = sha1($hash_str);
    
    echo $signature;
    ?>
    
    <form name="checkout" method="post" action="">
    <input type="hidden" name="A" value="<?php echo $A; ?>" />
    <input type="hidden" name="B" value="<?php echo $B; ?>" />
    <input type="hidden" name="C" value="<?php echo $C; ?>" />
    <input type="hidden" name="D" value="<?php echo $D; ?>" />
    <input type="hidden" name="E" value="<?php echo $E; ?>" />
    <input type="hidden" name="SIGNATURE" value="<?php echo $signature; ?>" />
    </form>
    
    </body>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 用vivado写数字逻辑实验报告撰写,FPGA实验
  • ¥15 为什么shp文件会有这种小方块?
  • ¥15 ecplise在连接数据库时显示加载驱动成功但是数据库连接失败
  • ¥15 visionmaster启动失败,提示为“机器不满足授权而被禁用”
  • ¥15 IDEA中圈复杂度如何具体设置
  • ¥50 labview采集不了数据
  • ¥15 Multisim红外倒车雷达仿真中距离问题
  • ¥15 请上面代码做什么处理或什么混淆
  • ¥15 英雄联盟自定义房间置顶
  • ¥15 W5500网线插上无反应