doushi3803 2014-09-20 20:04
浏览 61
已采纳

表单 - 点击提交后重定向

I am looking to get my form to redirect after the submit button is pressed.. but I am not sure what I am doing in correctly.

<?php


$user_id = example;
$game_id = 'example';
$value = $_POST['value'];
$date = date(mdyHis);
$secret = "example";
$username = $_POST['username'];
$hash = md5($user_id.$username.$game_id.$value.$date.$secret);
$redeem_link="http://www.example.com/".$user_id."&userNAME=".$username."&gameID=".$game_id."&value=".$value."&dateTime=".$date."&key1=".$hash;

if($_POST['submit']){
    header( 'Location: ".$redeem_link."' ) ;
} 

?>

And here is my form code.

<form action='?' method='post'> 
<td>
<center>
<div class="form-group">
<input type="text" class="form-control" id="username" name="username" placeholder="Enter Username">
</div>
<div class="form-group">
<input type="text" class="form-control" id="password" name="value" placeholder="Enter Amount">
</div>
</tr>
<tr><td><center><button class="btn btn-lg btn-primary" action="" type='submit' name='submit' value='Submit'>Submit</button></center></td></tr>
</form>
  • 写回答

2条回答 默认 最新

  • duan1989643 2014-09-20 20:05
    关注

    The line you should look at is: header( 'Location: ".$redeem_link."' ) ;

    It should be: header( 'Location: ' . $redeem_link ) ;

    Essentially, your code states, Location: ".http://www.example.com/.", which is not what you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?