Code organisational issue,markup

I am facing a problem with the markup of a registration form.
The user is presented with some links and each of them when clicked leads to a registration form-so far everything is OK.

But when the submit button is clicked(and if errors are found) the user is taken to the registration form again-but this time the markup is different,the errors displayed.

In other words I have markup in my HTML file for two different registration forms(I mean the form is the same of course but the one appears when the link is clicked and the other when the submit button clicked.)

Take a look here http://hastebin.com/iriqiyepom.xml:
It is a mess…there are times that in the screen the same form appears twice.

How I could clean it up?

The reason that lead me using 2 forms is that the second contains markup for errors shown(span elements).

Silly thought but can you not use just the second form from the start, as then error strings are empty and doesn’t add anything, do they?

I think you need to post more code if anyone should be able to debug this.

1 Like

That’s how I do it.
Instead of having two forms. one without an element to hold messages and another with, I make sure to initialize the message as an empty string so the placeholder element doesn’t have anything in it and as long as the CSS is OK it won’t be visible on the rendered page. eg.

$message = ""; 
if($problem} {
  $message = "need password";
}
... 
<span><?php echo $message; ?></span> 

As a general rule of thumb, if you have the same code repeated in a script, you are doing something wrong. Keep it DRY.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.