Jump to content

Default value in text field


dc_jt

Recommended Posts


I have a form where the user can add a url using a text field.

I want to be able to have 'http://' in the text field all the time so they always put this before their website.

I have the following:

[code] <td >URL</td><td ><input class="fmfield200" type="text" name="url" value="<?=(isset($_POST['url']))?$_POST['url']:$aListing['url']?>"/></td>
</tr>
<tr>[/code]

How can I put it into this?

Thanks
Link to comment
https://forums.phpfreaks.com/topic/27449-default-value-in-text-field/
Share on other sites

[code]<td>URL</td><td><input class="fmfield200" type="text" name="url" value="<?php
if(isset($_POST['url']) && strpos($_POST['url'],"http://") === FLASE)
echo "http://".$_POST['url'];
elseif(isset($_POST['url']) && strpos($_POST['url'],"http://") !== FALSE)
echo $_POST['url'];
elseif(strpos($aListing['url'],"http://") === FASLE)
echo "http://".$aListing['url'];
else
echo $aListing['url'];
?>"/></td>
</tr>[/code]

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.