AzeS Posted March 23, 2017 Share Posted March 23, 2017 What am i doing wrong in the code ?i've read that i might do something wrong with the echo phrase, but i don't get what exacatly it is. <input type="Text" name="sen_add_dat_bil_fir" maxlength="200" required="True" placeholder="Firstname" value="<?php if (isset($_SESSION['user'])) { echo $curd->word($userRow['fname_bil'], 'UTF-8'); } else { if (!empty($_SESSION['auto_fill']['bil_adr'])) { echo $crud->word($_SESSION['auto_fill']['bil_adr']['cos_fis'], 'UTF-8'); } } ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/303523-input-disappears-after-login/ Share on other sites More sharing options...
Psycho Posted March 23, 2017 Share Posted March 23, 2017 (edited) What IS the problem? What are you expecting the code to do and what is is actually doing? One potential problem is that you have a scenario in which no value would be defined. But, since I have no clue on how your conditions are generated I have no idea if that is your problem. As to your code, my first suggesting is to stop injecting a mass of PHP logic into the HTML like that. Put your PHP logic at the top of your script and generate the dynamic content into a variable. Then output that variable in the HTML. EDIT: I do see a couple possible errors in your code. Look at the comments in the below revision example Example: <?php //Create code to determine value of the input field if (isset($_SESSION['user'])) { //This scenario ASSUMES that fname_bill is set, but the condition only tested //to see if user index in the Session is set. $firstnameValue = $curd->word($userRow['fname_bil'], 'UTF-8'); } elseif (!empty($_SESSION['auto_fill']['bil_adr'])) { //The condition is checking if the array index is NOT SET, but then //you try to reference that array index in generating the value $firstnameValue = $crud->word($_SESSION['auto_fill']['bil_adr']['cos_fis'], 'UTF-8'); } else { //Your original code had no logic to set the value based on neither //of the above two above conditions being true $firstnameValue = "?????"; } ?> <html> <body> <input type="Text" name="sen_add_dat_bil_fir" maxlength="200" required="True" placeholder="Firstname" value="<?php echo $firstnameValue; ?>"> </body> </html> Edited March 23, 2017 by Psycho Quote Link to comment https://forums.phpfreaks.com/topic/303523-input-disappears-after-login/#findComment-1544504 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.