tarun14110
tarun14110

Reputation: 990

Using php variable in HTML

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 />

Upvotes: 0

Views: 76

Answers (2)

isuruAb
isuruAb

Reputation: 2240

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 />

Upvotes: 0

Symeon Quimby
Symeon Quimby

Reputation: 869

You are missing a set of quotes for your value attribute

value="<?php echo $userProfile['institute']?>"

Upvotes: 3

Related Questions