32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?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
|
|
*/
|
|
}
|
|
?>
|