adv Posted September 30, 2008 Share Posted September 30, 2008 <?php if(isset($_POST['sub'])){ $ss=$_POST['test']; $ss1=$_POST['test1']; echo '<pre>'; print_r($_POST); echo '</pre>'; } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form1"> <input type="hidden" name="first" value="<?php echo $ss; ?>" /> <input type="hidden" name="second" value="<?php echo $ss1; ?> " /> <br /><br /> <input type="text" name="test" value="" /> <input type="text" name="test1" value="" /> <br /><br /> <input type="submit" name="sub" value="login" /> </form> the problem is that when i submit the page it shows like this Array ( [first] => [second] => [test] => asdasdas [test1] => adasdassa [sub] => login ) and when i submit with empty values in the 2 inputs it shows like this Array ( [first] => asdasdas [second] => adasdassa [test] => [test1] => [sub] => login ) why doesnt when i submit the page first time shows all the values like this Array ( [first] => asdasdas [second] => adasdassa [test] => asdasdas [test1] => adasdassa [sub] => login ) Quote Link to comment https://forums.phpfreaks.com/topic/126522-solved-quick-problem/ Share on other sites More sharing options...
sKunKbad Posted September 30, 2008 Share Posted September 30, 2008 Of course it works exactly how you programmed it. When the submitted values are posted back to the script, you are applying the values of test and test1 to variables, but that doesn't mean that they are in the post array. They finally make it to the post array when you submit the second time, because they were values in the form only on the second submission. Try this: <?php if(isset($_POST['sub'])){ $ss=$_POST['test']; $_POST['first']=$_POST['test']; $ss1=$_POST['test1']; $_POST['second']=$_POST['test1']; echo '<pre>'; print_r($_POST); echo '</pre>'; } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form1"> <input type="hidden" name="first" value="<?php echo $ss; ?>" /> <input type="hidden" name="second" value="<?php echo $ss1; ?> " /> <br /><br /> <input type="text" name="test" value="" /> <input type="text" name="test1" value="" /> <br /><br /> <input type="submit" name="sub" value="login" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/126522-solved-quick-problem/#findComment-654342 Share on other sites More sharing options...
adv Posted October 1, 2008 Author Share Posted October 1, 2008 cool i see now .. thanks alot skunk :* Quote Link to comment https://forums.phpfreaks.com/topic/126522-solved-quick-problem/#findComment-654555 Share on other sites More sharing options...
adv Posted October 2, 2008 Author Share Posted October 2, 2008 i dont think there is a need to open another tread ... the problem is this : <?php $s=$_POST['textfiled']; $s1=$_POST['textfield2']; if (isset($_POST['button'])) { if (empty($s)||empty($s1)) { $errLog=1; } } ?> <?php if ($errLog !=1) { ?> <form name="firstForm" method="post" action=""> <p> <input type="text" name="textfield" id="textfield"> </p> <p> <label> <input type="text" name="textfield2" id="textfield2"> </label> </p> <p> <input type="submit" name="button" id="button" value="Submit"> </p> </form> <p> </p> <?php } else { ?> <form name="secondForm" method="post" action=""> <p> <input type="text" name="textfield" id="textfield"> </p> <p> <label> <input type="text" name="textfield2" id="textfield2"> </label> </p> <p> <input type="text" name="textfield3" id="textfield3"> </p> <p> <input type="submit" name="button" id="button" value="Submit"> </p> </form> <p> </p> <?php } ?> the problem is when i submit the page and is empty one of the values is shows the second form but if i submit the second form and the inputs are not empty it redirects me to the first form i`ve tried with $_SESSION and it works ... but i wanna know is there is a way just with variables when i submit the second form and the values are not empty i just wanna show lets say thanks in advance echo 'good'; Quote Link to comment https://forums.phpfreaks.com/topic/126522-solved-quick-problem/#findComment-655453 Share on other sites More sharing options...
adv Posted October 3, 2008 Author Share Posted October 3, 2008 anybody :?? :| Quote Link to comment https://forums.phpfreaks.com/topic/126522-solved-quick-problem/#findComment-656417 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.