rh-penguin Posted April 12, 2007 Share Posted April 12, 2007 Im trying to make a script where a user needs to input a specific number in order to move on to a diferent page(kinda like a login). This is what i've got so far but line 22(where the form starts) seems to have got me.........I dont know maybe the other code is crap???? ??? <html><head><title>Random number</title></head> <body> <?php $random_number = rand(1567, 9884); echo "Random number is:" . $random_number ; ?> <?php $enter_code = $_POST['enter_code']; $self = $_SERVER['PHP_SELF']; ?> <?php if(isset($_POST['enter_code']) and ($_POST['enter_code'] = $random_number) ) { echo "<a href=go_on.php>Continue!</a>; } else { echo ('Try again!'); } ?> <form action="<?php $self ?>" method="post"> Code: <input type="text" name="enter_code"><br> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
Orio Posted April 12, 2007 Share Posted April 12, 2007 The comparison operator is == and not =. The if line should be like this: if(isset($_POST['enter_code']) and ($_POST['enter_code'] == $random_number) ) { Also, you didn't close the double quotes in the echo statement. It should be like this: echo "<a href=go_on.php>Continue!</a>"; Orio. Quote Link to comment Share on other sites More sharing options...
rh-penguin Posted April 12, 2007 Author Share Posted April 12, 2007 It works fine now, thank you. The problem was within ("") but the error was telling me that line 22 was wrong(the form) Why is that?> Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 12, 2007 Share Posted April 12, 2007 sometimes an error on line 21 can cause line 22 to mess up.. like if you have $message = "hello world" // Line 21 echo $message; // Line 22 then since I forgot the ';' on line 21, the next line cant run properly Quote Link to comment Share on other sites More sharing options...
rh-penguin Posted April 12, 2007 Author Share Posted April 12, 2007 o ok....... Neways, 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.