imarockstar Posted November 12, 2008 Share Posted November 12, 2008 I am passing variables through a URL ... I have a file that redirects the user with a success code, like this : header("Location: ../editsettings.php?hai=uploaded"); On the next page I have a message displayed based on what the passed variable is, like this : <?php if ( $hai == uploaded ) { echo "The if statement evaluated to true"; } else { echo "The if statement evaluated to false"; } ?> this is not working... does my variable that is passed need to be a number ? Is there a way to where I can use the if else statement with a word or a string of words ? Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted November 12, 2008 Share Posted November 12, 2008 <?php if ( $_GET['hai'] == "uploaded" ) { echo "The if statement evaluated to true"; } else { echo "The if statement evaluated to false"; } ?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 12, 2008 Share Posted November 12, 2008 There are (most likely) two problems. Firstly, As MatthewJ showed, strings must be delimited by quotes. Otherwise, PHP treats them as constants. Now, if PHP cannot find a constant of that name, it will assume it was supposed to be a string. But, depending on your error reporting level, you may get errors. It's certainly not good practice to rely on this kind of thing. Second, unless you have register_globals turned on (which you shouldn't), you need to retrieve the value from the $_GET array like so: $hai = $_GET['hai']; Quote Link to comment Share on other sites More sharing options...
imarockstar Posted November 12, 2008 Author Share Posted November 12, 2008 sorry I didnt include the get code .. its at the top of te page ... But you guys did answer my question !! thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.