ArizonaJohn Posted May 21, 2009 Share Posted May 21, 2009 Hello, The form below takes input from the user, and adds a row to a table in a MySQL database. It works great. However, I would like to modify the user's input as follows: 1. If the user's input starts with "http://" I would like to remove the "http://". 2. If the user's input starts with "http://www." I would like to remove the "http://www.". 2. If the user's input starts with "www." I would like to remove the "www.". How can I do this? Thanks in advance, John <form action="process.php" method="post"> Add a website to this category: <input name="site" type="text" size="50"> <input type="submit" value="Submit"> </form> <? $site=$_POST['site']; mysql_connect("mysqlv3", "username", "password") or die(mysql_error()); mysql_select_db("sand2") or die(mysql_error()); mysql_query("INSERT INTO `santafe` VALUES (NULL, '$site',1,0)"); ?> Link to comment https://forums.phpfreaks.com/topic/159115-solved-trimming-the-input-from-an-html-form/ Share on other sites More sharing options...
gevans Posted May 21, 2009 Share Posted May 21, 2009 <?php $remove_array = array('http://www.', 'http://', 'www.'); $site = str_replace($remove_array, "", $_POST['site']); Link to comment https://forums.phpfreaks.com/topic/159115-solved-trimming-the-input-from-an-html-form/#findComment-839116 Share on other sites More sharing options...
ArizonaJohn Posted May 21, 2009 Author Share Posted May 21, 2009 Hi gevans, Works like charm. Thanks! -John Link to comment https://forums.phpfreaks.com/topic/159115-solved-trimming-the-input-from-an-html-form/#findComment-839162 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.