0
0
This repository has been archived on 2020-08-03. You can view files and clone it, but cannot push or open issues or pull requests.
bryanpedini.it_old/contactme/webform.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
*/
}
?>