<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>An &amp;quot; if statement &amp;quot; (or something similar) for a textfield</title>
        <link>https://interactivetools.com/forum/forum-posts.php?An-if-statement-or-something-similar-for-a-textfield-79059</link>
        <description></description>
        <pubDate>Mon, 15 Jun 2026 01:36:11 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;An-if-statement-or-something-similar-for-a-textfield-79059" rel="self" type="application/rss+xml" />

                <item>
          <title>An &quot; if statement &quot; (or something similar) for a textfield</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2232043#post2232043</link>
          <description><![CDATA[<p>Thanks Larry, I´ll give it a try. Thanks for your time. </p>]]></description>
          <pubDate>Sun, 06 Oct 2013 19:27:46 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2232043#post2232043</guid>
        </item>
                <item>
          <title>An &quot; if statement &quot; (or something similar) for a textfield</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2232042#post2232042</link>
          <description><![CDATA[<p>Blargh I always forget that trim aint allowed.</p>
<p><code>&lt;p&gt;&lt;span&gt; Website: &lt;/span&gt; &lt;?php if( ! empty(  $record['info_map_link'] ) : ?&gt;&lt;a href="&lt;?php echo <br />htmlencode($record['info_map_link']) ?&gt;" target="_blank"&gt; click <br />here &lt;/a&gt;&lt;?php endif ?&gt;&lt;/p&gt;here &lt;/a&gt;&lt;?php endif ?&gt;&lt;/p&gt;</code></p>
<p>Try thsi to use trim alone to make sure someone putting a few spaces in doesn't break it...</p>
<p><code>&lt;?php<br />$record['info_map_link'] = trim( $record['info_map_link'] );<br />?&gt;<br />&lt;p&gt;<br />    &lt;span&gt; Website: &lt;/span&gt; <br />        &lt;?php if( ! empty(  $record['info_map_link'] ) ) : ?&gt;<br />            &lt;a href="&lt;?php echo htmlencode( $record['info_map_link'] ) ?&gt;" target="_blank"&gt; click here &lt;/a&gt;<br />        &lt;?php endif ?&gt;<br />&lt;/p&gt;</code></p>
<p>That should be better, but this one will 'validate' a url, assuming your server allows it...</p>
<p><code>&lt;?php<br />$record['info_map_link'] = trim( $record['info_map_link'] );<br />if( $record['info_map_link'] )<br />{<br />    $array = get_headers( $record['info_map_link'] );<br />    if( ! strpos( $array[0], "200" ) ) $record['info_map_link'] = '';<br />?&gt;<br />&lt;p&gt;<br />    &lt;span&gt; Website: &lt;/span&gt; <br />        &lt;?php if( $record['info_map_link'] ) : ?&gt;<br />            &lt;a href="&lt;?php echo htmlencode( $record['info_map_link'] ) ?&gt;" target="_blank"&gt; click here &lt;/a&gt;<br />        &lt;?php endif ?&gt;<br />&lt;/p&gt;</code></p>
]]></description>
          <pubDate>Sun, 06 Oct 2013 18:55:53 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2232042#post2232042</guid>
        </item>
                <item>
          <title>An &quot; if statement &quot; (or something similar) for a textfield</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2232041#post2232041</link>
          <description><![CDATA[<p>Great, that works!, thanks a lot!</p>
<p>Carlos</p>]]></description>
          <pubDate>Sun, 06 Oct 2013 18:40:17 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2232041#post2232041</guid>
        </item>
                <item>
          <title>An &quot; if statement &quot; (or something similar) for a textfield</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2232040#post2232040</link>
          <description><![CDATA[<p>Hi Carlos,</p>
<p>Try this...</p>
<p><span><code><span style="color:#000000;"><span style="color:#000000;">&lt;?php if($record['info_map_link'] ): // checks for existence of a map link ?&gt;<br />&lt;?php </span><span style="color:#000000;">if(!</span><span style="color:#000000;">preg_match</span><span style="color:#000000;">(</span><span style="color:#000000;">"/^https:\/\//i"</span><span style="color:#000000;">, </span><span style="color:#000000;">$record</span><span style="color:#000000;">[</span><span style="color:#000000;">'info_map_link'</span><span style="color:#000000;">] )): // These check for a properly formatted link in the field </span><span style="color:#000000;">?&gt;<br /></span> <span style="color:#000000;">&lt;?PHP </span><span style="color:#000000;">if (!</span><span style="color:#000000;">preg_match</span><span style="color:#000000;">(</span><span style="color:#000000;">"/^http:\/\//i"</span><span style="color:#000000;">, </span><span style="color:#000000;">$record</span><span style="color:#000000;">[</span><span style="color:#000000;">'info_map_link'</span><span style="color:#000000;">])) {<br /></span><span style="color:#000000;">$record</span><span style="color:#000000;">[</span><span style="color:#000000;">'info_map_link'</span><span style="color:#000000;">] = </span><span style="color:#000000;">"http://" </span><span style="color:#000000;">. </span><span style="color:#000000;">$record</span><span style="color:#000000;">[</span><span style="color:#000000;">'info_map_link'</span><span style="color:#000000;">]; } </span><span style="color:#000000;">?&gt;<br /></span><span style="color:#000000;">&lt;?PHP </span><span style="color:#000000;">endif </span><span style="color:#000000;">?&gt;<br />&lt;p&gt;&lt;span&gt; Website: &lt;/span&gt;&lt;a href="&lt;?php echo htmlencode($record['info_map_link']) ?&gt;" target="_blank"&gt;click here&lt;/a&gt;&lt;/p&gt;<br />&lt;?php endif ?&gt;</span></span></code></span><br />BTW: you'll need to supply at least a class value for the span before Website:</p>
<p>Hope this helps</p>
<p>Jerry Kornbluth</p>]]></description>
          <pubDate>Sun, 06 Oct 2013 18:12:46 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2232040#post2232040</guid>
        </item>
                <item>
          <title>An &quot; if statement &quot; (or something similar) for a textfield</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2232039#post2232039</link>
          <description><![CDATA[<p>Hi Larry , i´m getting this error: <b>Fatal error</b>: Can't use function return value in write context in <b>/home/observat/public_html/test.php</b> on line <b>320</b></p>
<p><b> At line 320 is your code:</b></p>
<p>&lt;p&gt;&lt;span&gt; Website: &lt;/span&gt; &lt;?php if( ! empty( trim( $record['info_map_link'] ) ) : ?&gt;&lt;a href="&lt;?php echo <br />htmlencode($record['info_map_link']) ?&gt;" target="_blank"&gt; click <br />here &lt;/a&gt;&lt;?php endif ?&gt;&lt;/p&gt;</p>]]></description>
          <pubDate>Sun, 06 Oct 2013 17:42:39 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2232039#post2232039</guid>
        </item>
                <item>
          <title>An &quot; if statement &quot; (or something similar) for a textfield</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2232038#post2232038</link>
          <description><![CDATA[
<p><code>&lt;p&gt;&lt;span&gt; Website: &lt;/span&gt; &lt;?php if( ! empty( trim( $record['info_map_link'] ) ) : ?&gt;&lt;a href="&lt;?php echo <br />htmlencode($record['info_map_link']) ?&gt;" target="_blank"&gt; click <br />here &lt;/a&gt;&lt;?php endif ?&gt;&lt;/p&gt;</code></p>
]]></description>
          <pubDate>Sun, 06 Oct 2013 14:53:20 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2232038#post2232038</guid>
        </item>
                <item>
          <title>An &quot; if statement &quot; (or something similar) for a textfield</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2232037#post2232037</link>
          <description><![CDATA[<p>Hi,</p>
<p><strong>In an editor, I have a textfield to enter urls. This textfield it's not required, so, users of the cmsb may leave it blank.</strong></p>
<p><strong>This is the code in the frontend:</strong></p>
<p>&lt;p&gt;&lt;span&gt; Website: &lt;/span&gt;&lt;a href="&lt;?php echo htmlencode($record['info_map_link']) ?&gt;" target="_blank"&gt; click here &lt;/a&gt;&lt;/p&gt;</p>
<p><strong>When they enter the urls there's no problem. The problem appears when they don´t write an URL. Because, when the website visitors see the text "click here " and they click it, obviously, nothing happens.</strong></p>
<p><strong>I want the text "click here" to appear only if the cmsb user writes an url.</strong></p>
<p><span style="text-decoration:underline;"><strong>How can i do this?</strong></span></p>
<p>Carlos</p>]]></description>
          <pubDate>Sat, 05 Oct 2013 18:15:44 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2232037#post2232037</guid>
        </item>
              </channel>
    </rss>
  