0

I am using a php variable in html. $userProfile['institute'] is displaying correct value whenever $userProfile['institute'] is non-empty. When $userProfile['institute'] is empty , it display '/'. What may be the issue here ?

Institute: <input type="text" name="institute" value=<?php echo $userProfile['institute']?> /><br />

2 Answers 2

3

You are missing a set of quotes for your value attribute

value="<?php echo $userProfile['institute']?>"
Sign up to request clarification or add additional context in comments.

1 Comment

It is good practice to use htmlentities to prevent injection attacks. <?= htmlentities($userProfile['institute']) ?>
0

You should add double quotes around it like this (like you have wrapped value of type and institute attributes )

Institute: <input type="text" name="institute" value=" <?php echo $userProfile['institute']?>" /><br />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.