Question : PHP error handling, how to add error text to html

I have installed a php contact form script that works fine on a static website.   I need to amend the script below so that error messages are displayed in a html form as part of the website as oppose to just plain text.

How can I do this?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
function died($error) {
		// your error code can go here?
                    ??I WANT TO PUT HTML PAGE HERE WITH ERRORS


		echo "We are very sorry, but there were error(s) found with the form your submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}
	
	// validation expected data exists
	if(!isset($_POST['first_name']) ||
		!isset($_POST['last_name']) ||
		!isset($_POST['email']) ||
		!isset($_POST['telephone']) ||
		!isset($_POST['comments'])) {
		died('We are sorry, but there appears to be a problem with the form your submitted.');		
	}

Answer : PHP error handling, how to add error text to html

Is this what you are looking for?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
function died($error) {
                // your error code can go here?
                    ??I WANT TO PUT HTML PAGE HERE WITH ERRORS
                ?>
                <b>all the html you want</b>
                <?
                echo "We are very sorry, but there were error(s) found with the form your submitted. ";
                echo "These errors appear below.<br /><br />";
                echo $error."<br /><br />";
                echo "Please go back and fix these errors.<br /><br />";
                die();
        }
        
        // validation expected data exists
        if(!isset($_POST['first_name']) ||
                !isset($_POST['last_name']) ||
                !isset($_POST['email']) ||
                !isset($_POST['telephone']) ||
                !isset($_POST['comments'])) {
                died('We are sorry, but there appears to be a problem with the form your submitted.');          
        }
Random Solutions  
 
programming4us programming4us