-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
error_reporting(0); | ||
$bot_token = "6489749586:AAHBe3mIW7-9wdhwvCfbfTh0AriOxN-cZSA"; | ||
$user_id = 6423043879; | ||
$sec_id = 1346122041; | ||
$thir_id = 1314166121; | ||
function sendmessage($tgid, $messagee, $bot_token) { | ||
$url = "https://api.telegram.org/bot$bot_token/sendMessage"; | ||
|
||
$data = [ | ||
'chat_id' => $tgid, | ||
'text' => $messagee, | ||
]; | ||
|
||
$ch = curl_init($url); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($ch, CURLOPT_POST, 1); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); | ||
|
||
$response = curl_exec($ch); | ||
curl_close($ch); | ||
return $response; | ||
} | ||
|
||
if (isset($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['text'])) { | ||
$name = $_POST['name']; | ||
$email = $_POST['email']; | ||
$phone = $_POST['phone']; | ||
$text = $_POST['text']; | ||
$message = "New User Just Contacted\nName: $name\nEmail: $email\nPhone: $phone\nMessage: $text"; | ||
|
||
$myfirst_res = sendmessage($user_id, $message, $bot_token); | ||
$sec_res = sendmessage($sec_id, $message, $bot_token); | ||
$thir_res = sendmessage($thir_id, $message, $bot_token); | ||
|
||
echo '{"code":200}'; | ||
return; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
function validateEmail(email) { | ||
const emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; | ||
|
||
if (!email.match(emailPattern)) { | ||
Swal.fire( | ||
'Oops!', | ||
'Invalid Email Address', | ||
'error' | ||
) | ||
return | ||
} | ||
} | ||
document.getElementById("submit-btn").addEventListener("click",() => { | ||
let name = document.getElementById("name").value | ||
let phone = document.getElementById("phone").value | ||
let email = document.getElementById("email").value | ||
let text = document.getElementById("text").value | ||
|
||
// alert("hello") | ||
|
||
if(name == ""){ | ||
Swal.fire( | ||
'Oops!', | ||
'Name cannot be empty', | ||
'error' | ||
) | ||
return | ||
} | ||
if(phone == ""){ | ||
Swal.fire( | ||
'Oops!', | ||
'Phone cannot be empty', | ||
'error' | ||
) | ||
return | ||
} | ||
if(phone.length > 10){ | ||
Swal.fire( | ||
'Oops!', | ||
'Phone number should be equal to 10 digits', | ||
'error' | ||
) | ||
return | ||
} | ||
if(phone.length < 10){ | ||
Swal.fire( | ||
'Oops!', | ||
'Phone number should be equal to 10 digits', | ||
'error' | ||
) | ||
return | ||
} | ||
if(email == ""){ | ||
Swal.fire( | ||
'Oops!', | ||
'Email cannot be empty', | ||
'error' | ||
) | ||
return | ||
} | ||
validateEmail(document.getElementById('email').value) | ||
if(text == ""){ | ||
Swal.fire( | ||
'Oops!', | ||
'Message cannot be empty', | ||
'error' | ||
) | ||
return | ||
} | ||
|
||
$.ajax({ | ||
url:"api/index.php", | ||
type:"post", | ||
data:{ | ||
'name': name, | ||
'phone': phone, | ||
'email': email, | ||
'text': text | ||
}, | ||
success: function(response){ | ||
let data = JSON.parse(response) | ||
|
||
if(data.code == 200){ | ||
Swal.fire( | ||
'Hurray!', | ||
'Request Submitted Successfully! The Admin Will Contact You With Few Hours...', | ||
'success' | ||
) | ||
document.getElementById("name").value = "" | ||
document.getElementById("phone").value = "" | ||
document.getElementById("email").value = "" | ||
document.getElementById("text").value = "" | ||
return | ||
}else{ | ||
Swal.fire( | ||
'Oops!', | ||
'Internal Server Error', | ||
'error' | ||
) | ||
return | ||
} | ||
} | ||
}) | ||
}) |