[PHP] Help with a switch and a redirect
2015-06-02, 06:27 PM,
#1
Hi, I'm new to PHP and I can't find why my script is not redirecting. Here is my code:

PHP Code:
<?php 

$myvariable 
$_GET['n'];

switch (
$myvariable) {
    
    case 
0:
    include 
'0.php';
    break;
    
    case 
1:
    include 
'1.php';
    break;

// There is more cases...

    
default:
    
header("Location: http://google.com");
        break;
}

?>

If I visit "mywebsite/index.php?n=0" it will load the file 0.php but if I put an invalid value like "mywebsite/index.php?n=a" it is not redirecting to "http://google.com". Any help is appreciated. Thanks!.
Reply
2015-06-02, 07:35 PM,
#2
Hello try changing the case number to a string data type.

change the ---> case 0: TO case "0":
and do it in all other cases.

It should work.
Latest Thanks - View all

Aamobu(2015-06-02 07:47 PM) 

[Image: Z6bbLae.gif]



I LOVE CPAELITES!


Reply
2015-06-02, 07:47 PM,
#3
(2015-06-02, 07:35 PM)Gunslinger Wrote: Hello try changing the case number to a string data type.

change the ---> case 0: TO case "0":
and do it in all other cases.

It should work.

Thank you very much, it's working. My bad, a silly mistake. Embarrassed Embarrassed
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Help Needed CPAgrip php script takumi 4 797 2017-01-24, 04:47 AM
Last Post: takumi
  SOME DATA IS NOT BEING INSERTED TO MYSQL DATABASE WITH PHP QwertySon 2 1,138 2016-11-21, 02:52 PM
Last Post: QwertySon
  Mobile traffic redirect after clicks on button Warriorcpa 2 1,092 2016-10-01, 05:54 PM
Last Post: Warriorcpa
  php + mysql , I need help t0ks1ck 4 1,036 2016-09-19, 01:55 AM
Last Post: styx
  need a php line help t0ks1ck 8 1,028 2016-09-08, 09:01 PM
Last Post: styx




About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top