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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.