web_master Posted July 20, 2008 Share Posted July 20, 2008 Hi, I try to check input valu, when somebody enter his name in form, but its dont work... step 1: the form is empty step 2: if the form is still "empty" (only the "generic" text is in) step 3: user is enter the text what Im I do wrong? <?php // POST submit if($_POST['submit']) { // step 1 if($_POST['user'] == "") { if($_POST['lg'] == "hu") {$user_print = "EMPTY ON HU";} if($_POST['lg'] == "es") {$user_print = "EMPTY ON ES";} $user = $user_print; // step 2 } elseif($_POST['user'] == $user_print) { if($_POST['lg'] == "hu") {$user_print2 = "EMPTY ON HU2";} if($_POST['lg'] == "es") {$user_print2 = "EMPTY ON ES2";} $user = $user_print2; // step 3 } else { $user = $_POST['user']; } } // end of POST submit ?> <form action="<?php print $_SERVER['PHP_SELF'];?>" method="post"> <input type="text" name="user" value="<?php print $user;?>" /> <input type="submit" name="submit" /> <input type="hidden" name="lg" value="hu" /><!-- or value="es" --> </form> Link to comment https://forums.phpfreaks.com/topic/115684-check-input-value-dont-work/ Share on other sites More sharing options...
ignace Posted July 20, 2008 Share Posted July 20, 2008 if ($_POST['user'] == $user_print) will never be correctly evaluated because at that point $user_print has not declared and is therefor converted to NULL so only when $_POST['user'] is NULL or equivalent the statement will pass Link to comment https://forums.phpfreaks.com/topic/115684-check-input-value-dont-work/#findComment-594749 Share on other sites More sharing options...
web_master Posted July 20, 2008 Author Share Posted July 20, 2008 Yes, this is the problem... how can I made it, to work? Link to comment https://forums.phpfreaks.com/topic/115684-check-input-value-dont-work/#findComment-594750 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.