douhuanbai6729 2010-01-18 18:56
浏览 38
已采纳

重定向if语句不起作用

Hey, I am trying to make an if statement that redirects them to a different page if true, simple right?

I am not sure why this is not working but I am using:

if ($_POST['accounttype']=='Paid User - £2 p/m'){
    $userid = strtolower($_SESSION['X2X2']);
    $getuser = mysql_query("SELECT * FROM XXXXXX WHERE X2X2 = '$userid'");
    $info = mysql_fetch_array($getuser);
    $id = $info['X3X3'];
    mysql_query("UPDATE members SET payment = '" . mysql_real_escape_string("XXXXXXXX"). "' WHERE X3X3 = $id");
    header('Location: http://beta.XXXXX.co.uk/purchase.php');
    mysql_close($con);
}

When I put

<?
echo $_POST['accounttype'];
?>

And I get back

Paid User - £2 p/m

Which is correct?

Any help would be appreciated, Thanks.

  • 写回答

5条回答 默认 最新

  • dongzj2015 2010-01-18 19:47
    关注

    As it seems to depend on £, you have several possibilities depending on which values $_POST['accounttype'] can have.

    First I suggest you try:

    if ($_POST['accounttype']=='Paid User - &pound;2 p/m'){
    

    (as &pound; is £ in HTML).
    If this doesn't work, what is the part of the string, that makes it unique? Paid User or 2 p/m? If any of these, it is sufficient to check against a substring like:

    if (substr($_POST['accounttype'],-5)=='2 p/m'){
    

    or

    if (substr($_POST['accounttype'],0,9)=='Paid User'){
    

    or any combination (avoiding £).

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

报告相同问题?

悬赏问题

  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi