【问题标题】:stripping a text from a form从表单中删除文本
【发布时间】:2009-07-02 23:11:42
【问题描述】:

这里是输入表单代码

<tr valign="top">
    <td align="right" class="innertablestyle"><font class="normal"><strong>Homepage</strong></font></td>
    <td>&nbsp;</td>
    <td>
        <font class='normal'>
            http://
            <input name="website" type="text" id="website" value="<?php echo $website; ?>">
            &nbsp;
        </font>
        <font class="normal">&nbsp; </font>
    </td>
</tr>

这里是显示代码

<tr > 
<td height="25" class="selllink"> Website 
Address<font class="h2">&nbsp;&nbsp;&nbsp; 

<?php 
$group_set=mysql_fetch_array(mysql_query("select * from b2b_groups where sb_memtype=".$mem["sb_memtype"])); 
if(($sbrow_off["sb_website"]<>"")&&($group_set["sb_posturl"]=='yes')) 
{echo "<a href='http://".$sbrow_off["sb_website"]."' target='_blank'>".$sbrow_off["sb_website"]."</a>"; } 
else 
{echo $config["sb_null_char"];} 
?> 
</font></td> 
</tr> 

收集用户 url 以存储在数据库中的表单。他们不应该用他们的 URL 输入 http://,无论多么多,结果是当他们的 url 显示时,它看起来像这样

http;//http://www.foo.com我需要表单来剥离或忽略它,或者你认为最好的处理方式。

【问题讨论】:

    标签: php html forms


    【解决方案1】:
    if (stripos($website, "http://") === 0) 
        $website = substr($website, 7);
    

    【讨论】:

      猜你喜欢
      • 2016-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      相关资源
      最近更新 更多