What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Newbie PHP Question about Null Redirects

    Asked by Robbin 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 - 

     

    If

    the href is "   (null or empty)    "  

    then redirect

    to "http://mydomain.com/missingsocial.php" 

     

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

    Thanks, Robbin

     

     

  • Profile Image
    JotForm Support

    Answered by jonathan 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.

    Thanks.