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> Link to comment https://forums.phpfreaks.com/topic/46697-solved-can-someone-review-this-code-please/ 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. Link to comment https://forums.phpfreaks.com/topic/46697-solved-can-someone-review-this-code-please/#findComment-227476 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?> Link to comment https://forums.phpfreaks.com/topic/46697-solved-can-someone-review-this-code-please/#findComment-227483 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 Link to comment https://forums.phpfreaks.com/topic/46697-solved-can-someone-review-this-code-please/#findComment-227487 Share on other sites More sharing options...
rh-penguin Posted April 12, 2007 Author Share Posted April 12, 2007 o ok....... Neways, thanks! Link to comment https://forums.phpfreaks.com/topic/46697-solved-can-someone-review-this-code-please/#findComment-227489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.