javascript inside php

16,993

You forgot to wrap string with quotes in alert .

"Your downlaod key is wrong, Please try again!" is a string

if(isset($_POST['downloadkey'])){
                $key = $_POST['downloadkey'];
                if($key != $data['download_key']){
                    echo 'Your key is wrong.';
                    echo '<script type="text/javascript"> alert("Your downlaod key is wrong, Please try again!");</script>';
                }
            }
Share:
16,993
Faryal Khan
Author by

Faryal Khan

Updated on June 14, 2022

Comments

  • Faryal Khan
    Faryal Khan almost 2 years

    How can i write a javascript alert inside php ? For example if i want to popup a javascript alert in this if condition how I can do it ?

    if(isset($_POST['downloadkey'])){
                    $key = $_POST['downloadkey'];
                    if($key != $data['download_key']){
                        echo 'Your key is wrong.';
                        echo '<script type="text/javascript"> alert(Your downlaod key is wrong, Please try again!);</script>';
                    }
                }
    

    Thanks in advance