I’m getting 502 error on my some insert queries, data is inserting into table but throwing an 502 error
Could you please fill in the topic template so we have a bit more than a vague description and a status code?
Sorry for late response,
Php code
<?
if(!isset($_COOKIE["alp_user_login"]) && empty($_COOKIE["alp_user_login"])) header('Location: ./login'); else
require 'app/classes/assets.php';$assets = new assets();$row = $assets->getLogin_credentials();
if(isset($_POST["submit"])){
$conn = $assets->conn();
$subject = strip_tags(htmlspecialchars($conn->real_escape_string(str_replace(" ", " ", trim($_POST["subject"])))));
$email = $row["user_email"];
$form_by = $row["user_name"];
$class = strip_tags(htmlspecialchars($conn->real_escape_string($_POST["class"])));
$date = strip_tags(htmlspecialchars($conn->real_escape_string($_POST["date"])));
$mm = strip_tags(htmlspecialchars($conn->real_escape_string($_POST["mm"])));
$visible = strip_tags(htmlspecialchars($conn->real_escape_string($_POST["visible"])));
$hide = strip_tags(htmlspecialchars($conn->real_escape_string($_POST["hide"])));
$data = strip_tags(htmlspecialchars($conn->real_escape_string(str_replace(" ", " ", trim($_POST["form_url"])))));
# print_r($data);
$msg = "";
$unique_id = "alp-form-".$subject."-".$class."-".$date;
$formId=$assets->randomPassword(16, 1, "lower_case,upper_case,numbers");
$form_id = $formId[0];
echo $form_id."<br>".$subject."<br>".$class."<br>".$mm."<br>".$visible."<br>".$hide."<br>".$data."<br>".$form_by;
$true = 1;
$stmt = $conn->prepare("INSERT INTO alp_forms(form_id, subject, class, mm, visible_time, hide_time, form_by, user_email, isGoogle_form, g_url) VALUES(?,?,?,?,?,?,?,?,?,?)");
$stmt->bind_param("ssssssssis", $form_id, $subject, $class, $mm, $visible, $hide, $form_by, $email, $true, $data);
$stmt->execute();
if($stmt){
$api = "abcd123*#=+$";
$url = "https://forms.alapdorl.xyz/public/t?v=".$form_id;
$json = json_decode($assets->curl_get_contents("https://cutt.ly/api/api.php?key=".$api."&short=".$url), true);
# echo $url."<br>";
# $msg = 'Your form has been imported successfully.<br>And here your form url <a href="'.$json["url"]["shortLink"].'">'.$json["url"]["shortLink"].'</a>';
# echo $json["url"]["shortLink"];
header('Location: ./dashboard?url='.$json["url"]["shortlink"]);
} else{
$msg = "Sorry there was an internal error occured during processing, please try again later. Or <a href='/#contact-section'>Contact us</a>.";
}
echo $msg."<br>";
}
?>
Please remember that this is a publicly accessible forum, so never share any sensitive data (like passwords) here. I just reset your account password.
As for your code, maybe the cutt.ly API is slow and preventing the successful execution of your code? Does the API call have a timeout set?
Can you try instead of <?
use <?php
@HaydenANG Yess
First thank you so much for step and I’m really Sorry that I mistakenly shared my password, and I’m changing api from Cutt.ly
to another.
@Admin Sorry for disturbing you can you please suggest me good URL shortener api
I personally use rebrand.ly
@HaydenANG Thanks for your suggestion
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.