I have staff.php
page which contains staff's name,position and detail.When user would need to edit staff info,they would be send to edit.php
page.edit.php
page show name and title on text field
and detail on a textarea
My question is,do I even need htmlspecialchars
in edit.php
page.I am not printing anything to users page,only on that fields.But I'm using htmlspecialchars
on staff.php
before printing to user.
Is it still open to XSS Attack
?
Code
part from staff.php
$staff.="<div id='sob'>".htmlspecialchars($title)."<br>".htmlspecialchars($sub_title)."<div><a href='edit.php?pid=".htmlspecialchars($pro_id)."'><input type='submit' id='editx' name='editx' value='Edit'></a></div><div id=''><br>".htmlspecialchars($detail)."</div><hr id='h'></div>";
part from edit.php
if(isset($_GET["pid"])){
$name4=$title; //
$sub_title4=$sub_title; //using prepared statement
$detail4=$detail; //
}
HTML part at edit.php
<input type='text' id='staff_name' name='staff_name' value="<?php echo $name4;?>" required>
</br><input type='text' id='staff_pos' name='staff_pos' value="<?php echo $sub_title4;?>" required>
</br><textarea id='staff_detail' name='staff_detail' cols='30' rows='6' required><?php echo $detail4;?></textarea></br>