October 2017
Intermediate to advanced
370 pages
8h 57m
English
We won't dwell on the PHP server code as it's not strictly AMP. The code we use here is the following (/ch6/signup-xhr.php):
header('Content-Type: application/json');header('Access-Control-Allow-Credentials: true');header('Access-Control-Allow-Origin: https://theampbook-com.cdn.ampproject.org');header('Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin');header('AMP-Access-Control-Allow-Source-Origin: https://theampbook.com');$email = isset($_REQUEST["email"])?$_REQUEST["email"]:"";// Handle malformed email addressif(!filter_var($email, FILTER_VALIDATE_EMAIL)) { header("HTTP/1.0 400 Error"); $content = '{"email":"'.$email .'", "message":"The email address is not valid"}';}// Pretend it's already ...Read now
Unlock full access