Newbie PHP Question about Null Redirects

  • Profile Image
    Asked on May 26, 2012 at 04:19 PM

    Hi. I have a coding question. I am thinking this can be - hopefully fairly easily. 

    I have the following link set up and working with my jotform database and php - but need a way to redirect - if the print $answerArray is null. 

    Code - 

    <a target="_blank" href=" <?php print $answersArray['facebook']; ?>" ><img src="images/icons/facebook.png" width="32" height="32" alt="fb"></a>

    The current code works great until a user does not have a FB web url to insert in the jotform I have provided.  

    I would like to just redirect viewers to a standard url when this happens.  

    So basically I am looking for something like this - 



    the href is "   (null or empty)    "  

    then redirect

    to "" 


    Can this be done? Would someone please give me a point in the right direction? I would be so grateful. 

    Thanks, Robbin



  • Profile Image
    Answered on May 26, 2012 at 07:33 PM

    Hi Robbin,

    Can you please provide us the URL of the website where the form was used?

    I am not much of a PHP coder and you are probably using JotForm Application as I cannot find your form...

    But I found this code which I think can help in your inquiry on how to redirect using PHP code


    if($answerArray = null) {

     echo "<meta http-equiv=\"refresh\" content=\"0;URL=page_1.php\">";

    } else {

     echo "<meta http-equiv=\"refresh\" content=\"0;URL=page_2.php\">";


    Some of my colleague who are better in PHP would also provide an appropriate code when they see this.

    Please inform us if you have further inquiry.