PHP用户友好/智能表格(没有JS)

Im currently trying to develop a form that can work fully without JavaScript.

Basicly i want the user to be able to do the following:

  • Complete form
  • Submit form
  • Success(Update DB or what ever)
  • Fail (Go back to step 1 but with data from step 1 before already there)

I was thinking of doing the following for example:

<input type="text" value="<?php checkPost(name);?>"/>

Then in check post doing something like:

function checkPost($name){
    try{
       return  $_POST[name];
    }
    catch{
        return "";
    }
}

Would this stop the error:

Notice: Undefined index

Which means if the data wasnt posted then just set the value to "" but if it was posted then set the old value to it.

Is this the best way to do it can anyone tell me a smarter way to do this with my forms.

My form markup can be seen here: JS Fiddle

It will not stop error.
Because error is not an Exception in this case.

This sounds much better:

function checkPost(name){
    return isset($_POST['name']) ? $_POST['name'] : '';
}

My opinion - it is very bad idea to write validation functions for each for field.
Read about Zend_Form.
You can include it in your project even if you are not using ZF.