Jump to content

help stripping url


gammaman

Recommended Posts

I am trying to strip a url submitted via a form, down to the base address and then insert it into a database.

 

So assuming the url submitted reads www.abc.com/123/456/789/111

 

The url submitted to the database should be www.abc.com

 

 

I am trying to use the explode function to achieve this.  When I echo after doing the explode, the echo contains what I want.  However when I try to write to the database, nothing gets written.

 

 

<?php	
   include("connect.php");

   session_start();
   connect();
   // session_register('link');
   $_SESSION['link'] = explode("/", $_POST['link']);
  
   echo $_SESSION['link'][0];
   
   
   
   
   $insertQuery = "insert into sites(address)values(('".$_SESSION['link'][0]."'))";
   
   mysql_query($insertQuery);
?>

Link to comment
https://forums.phpfreaks.com/topic/265353-help-stripping-url/
Share on other sites

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.