Jump to content

input disappears after login...


AzeS

Recommended Posts

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');
						}
						}
						?>">
Link to comment
Share on other sites

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 by Psycho
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.