Blank php pages can be caused by -
- Php parse/syntax errors.
- Fatal php runtime errors.
- The php language is not installed or is not being invoked when/how the page gets requested.
- The php code is not outputting anything at all, is conditionally outputting content and the conditional logic is false, or is outputting content/php non-fatal runtime errors and is performing a header() redirect with php’s output_buffering being turned on.
For items #1 and #2, the errors that get reported and displayed or logged depend on php’s error related settings. The two paragraphs I wrote about the php error related settings need to be followed so that php will help you. Otherwise, you might as well be trying to program with your computer’s screen turned off. For item #1, you cannot put these settings into your code file and have them ‘work’ since the code in any file never runs when there is this type of error. Simply put these settings into the php.ini on your system.
For item #3, are you sure php is installed where you are executing this code, that you are using a URL, such as http://localhost/your_file.php, to request the file on the web server, and that the file has a .php extension? If the raw php code is not being executed on the server, it will be output to the browser. You may need to do a ‘view source’ in the browser to see the raw php code for a blank page.
For item #4, since the code does have an echo statement in it, it would require having all the relevant code needed to reproduce the problem, the form and the form processing code, in order to determine what is the most likely cause of the problem. When you are making the changes to the php.ini for the error related settings, you should also set output_buffering to OFF.
For the PDO connection code, you should set the error mode to exceptions (see the line that astonecipher included in his post above), set emulated prepared queries to false, and set the default fetch mode to assoc. For these later two settings, add this -
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES,false); // run real prepared queries
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); // set default fetch mode to assoc