Redisplay modal from PHP

I am using a modal to add new data to a database using an html form which submits the data to a PHP script. Everything works great if there are no errors detected by my PHP script but if I find any errors, I want to reload the modal to show the error message.

The modal includes a span with a php command to display the error from the variable set up by my PHP script, like thgis: