0

I am using htmlspecialchars($_POST['']) to keep the data submitted with errors on my registration form,

<form method="post" action="<?php echo htmlspecialchars( $_SERVER['PHP_SELF']) ;?> ">
    <div>Company</div>
    <input type="text" name="user_account" size="20"
        value="<?php echo htmlspecialchars($_POST['user_account']); ?>" 
        placeholder="Company Name">
    <input type="submit" name="submit" value="submit">
</form>

but before the page is submitted, I am getting unknown data where I am using the value="<?php echo htmlspecialchars($_POST['user_account']).

How can I solve this problem?

Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123
Aless
  • 25
  • 5
  • try this – Xrymz Jun 10 '15 at 11:51
  • If it's before the page is submitted, do you mean that you expect the `htmlspecialchars` function to apply to what the user enters immediately? – Geoff Atkins Jun 10 '15 at 11:51
  • when u dont submit form u $_POST['user_account'] is empty . – Xrymz Jun 10 '15 at 11:52
  • No GeoffAtkins, because before htmlspecialschars with input value is suppose to be empty, but doesn't it. thanks – Aless Jun 10 '15 at 12:06
  • 1
    Please define "unknown data" (show an example of the output). – Daniel W. Jun 10 '15 at 12:23
  • I am calling "unknown data" because dont know the data is comming from on my form, Im getting "
    Notice: Undefined index: user_account in /va..." instead empty or the "placeholder=" info.
    – Aless Jun 10 '15 at 12:41
  • @user1229266 — That's an error message because the index of POST you were trying to access doesn't exist. – Quentin Jun 12 '15 at 16:05
  • [The HTML5 placeholder attribute is not a substitute for the label element](http://www.456bereastreet.com/archive/201204/the_html5_placeholder_attribute_is_not_a_substitute_for_the_label_element/) – Quentin Jun 12 '15 at 16:06

0 Answers0