Is there any way to make this code perform faster?

Posted 4 months ago by behnampmdg3


Is there any way to make this code perform faster? Or is it as optimized as it can be.

It gets inconsistent traffic, up to 50k requests per second. So need to make it as light as possible.

include 'config.php';

if(isset($_POST['user_id']) && ctype_digit($_POST['user_id']) && 
   isset($_POST['launch_id']) && ctype_digit($_POST['launch_id']) && 
        $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        //Check Credentials
        $stmt = $conn->prepare("SELECT secret_key, launch_timezone FROM launch_owners INNER JOIN launch_launches ON launch_launches.user_id = WHERE = :id AND secret_key = :secret_key AND = :launch_id");
        $stmt->bindParam(':id', $_POST['user_id']);
        $stmt->bindParam(':secret_key', $_POST['secret_key']);
        $stmt->bindParam(':launch_id', $_POST['launch_id']);
                $result = $stmt->fetchAll();
                //Insert record
                    $stmt = $conn->prepare("INSERT INTO launch_temp_leads (user_id, launch_id, prospect_email, time_added, date_added, source) VALUES (:user_id, :launch_id)");
                    $stmt->bindParam(':user_id', $_POST['user_id']);
                    $stmt->bindParam(':launch_id', $_POST['secret_key']);
                    $stmt->bindParam(':prospect_email', $_POST['prospect_email']);
                    $stmt->bindParam(':time_added', date('i:H'));
                    $stmt->bindParam(':date_added', date('Y-m-d'));
                //Insert record    
        echo "Not sufficient post data";


Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.