-1

i have to display a cookie value in textbox
but the value is surrounded with a lot of space on both sides
i am appying trim() but still not fixing

 < ? php
 uName="";
 if(isset($_COOKIE["uName"]))
 { $uName=trim($_COOKIE["uName"]);}
 ?>
 <input type="text" name="uName" value="<?php echo $uName; ?>">   
Fakhr Alam
  • 203
  • 1
  • 5
  • 12

2 Answers2

1

Please fix error in 1st line of your code:

$uName = "";

For debug purposes I use functions, described in this article

Community
  • 1
  • 1
Valeriy Gorbatikov
  • 3,459
  • 1
  • 15
  • 9
0

I have solved it.
Error was here

<input type="text" value="<?php echo $_COOKIE["uName"]; ?>">

Now i have replaced this with

<input type="text" <?php echo "value='".$_COOKIE["uName"]."'"; ?> >

It's working fine now.

rhavendc
  • 985
  • 8
  • 21
Fakhr Alam
  • 203
  • 1
  • 5
  • 12