You've already forked bryanpedini.it_old
Updated author informations, updated location of included files, structured the website to the new layout, removed local fontawesome and moved to cloud CDN
This commit is contained in:
32
lib/php/contactme.php
Normal file
32
lib/php/contactme.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
function check_email ( $email ) {
|
||||
return filter_var ( $email, FILTER_VALIDATE_EMAIL );
|
||||
}
|
||||
|
||||
function post_call ( $url, $data ) {
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'content' => http_build_query ( $data )
|
||||
]
|
||||
];
|
||||
$context = stream_context_create ( $options );
|
||||
$result = file_get_contents ( $url, false, $context );
|
||||
if ( $result === FALSE ) { /* Handle error */ } // TODO: next thing to do
|
||||
}
|
||||
|
||||
if ( isset ( $_POST [ 'name' ] ) && isset ( $_POST [ 'email' ] ) && isset ( $_POST [ 'message' ] ) && check_email ( $_POST [ 'email' ] ) === false ) {
|
||||
$message = [
|
||||
'name' => $_POST [ 'name' ],
|
||||
'email' => $_POST [ 'email' ],
|
||||
'message' => $_POST [ 'email' ]
|
||||
];
|
||||
$message_json = json_encode ( $message );
|
||||
post_call ( 'https://telegram.bryanpedini.it/bots/personal-website-contactform.php', $message_json );
|
||||
/*
|
||||
if you need anything specific about telegram bots or you want to request me a custom made telegram bot,
|
||||
please contact me at info@telegram.bryanpedini.it
|
||||
*/
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user