Jump to content

[SOLVED] Trimming the input from an HTML form


ArizonaJohn

Recommended Posts

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)");


?> 

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.