dimanche 25 septembre 2016

Comparing null data through if statement

I am having trouble comparing a set variable to null. My code runs as

.......some code
echo "Question1 is" . $q1. "is Question-1";
?>

<html>
<head>  
<form method="post" method="post" action="jobprocess.php">
                            <?
                            if($q1!="")
                                { ?>

                             <h3> Answer the below simple questions related to the job and apply </h3>
                             <div align="center">
                            <input type="text" name="q1" required placeholder="<?php echo $q1;?>"><br>

                            <? } ..... some more code

The result is shown as

Question1 isis Question-1

Answer the below simple questions related to the job and apply

[Text Box]

While the first line confirms that variable q1 ="", I cannot understand why is it entering !$q1="" loop

Thank you for your patience I have gone through the usages of ===null and empty($var) before I have posted this and I am not able to figure out what is wrong with my code

Aucun commentaire:

Enregistrer un commentaire