Can ignore other post not sure why i closed it, not solved lol, not enough coffee too much looking at php anyway.
I have this form I'm working on and found something interesting
attempt1
this way works exactly how I want, which is nothing in the input boxes and no error messages on loading the registration form, once submit button is pressed the empty fields have a message appear next to them, the only problem is it does not validate on the w3 website
<label>Username</label><br />
<input name="name" type="text" value="<?php if(isset($_POST['name'])) echo $_POST['name'] ?>"/>
<?php if (!empty($arrErrors['name'])) echo '<span class="errortext">'.$arrErrors['name'].'</span>';?>
<br />
error message is, all errors underline the " after the word value
# Error Line 78, Column 47: XML Parsing Error: Unescaped '<' not allowed in attributes values
…nput name="name" type="text" value="<?php if(isset($_POST['name'])) echo $_P
✉
# Error Line 78, Column 47: XML Parsing Error: attributes construct error
…nput name="name" type="text" value="<?php if(isset($_POST['name'])) echo $_P
✉
# Error Line 78, Column 47: XML Parsing Error: Couldn't find end of Start Tag input line 78
…nput name="name" type="text" value="<?php if(isset($_POST['name'])) echo $_P
attempt 2
this code validates
<label>Username</label><br />
<input name="name" type="text" value="<?php if(isset($_POST['name'])) echo $_POST['name'] ?>"/>
<?php if (!empty($arrErrors['name'])) echo '<span class="errortext">'.$arrErrors['name'].'</span>';?>
<br />
however on loading the form this code appears in the text area which makes it look very ugly, it does this because of the < being changed to < and > to > and simply treats it as input
<?php if(isset($_POST['name'])) echo $_POST['name'] ?>
attempt 3
which validates
<label>Username</label><br />
<?php echo "<input name=\"name\" type=\"text\" value=\"" if(isset($_POST['name'])) echo $_POST['name'], "\" />";
if (!empty($arrErrors['name'])) echo '<span class="errortext">'.$arrErrors['name'].'</span>';
echo "<br />";
?>
but throws the following parse error, with line 79 being the line with input tag
Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\music good copies\register.php on line 79
what i need is to make the outcome of attempt 1 which is empty form on load and error messages when empty fields are attempted to be submitted with the code like attempt 3 so that it validates
validation is not critical as its for a php site that is hosted locally, however for future projects I would like to know the correct way.
cheers