Jump to content

Recommended Posts

hi

i been working on this code witch will add what ever text i want to my database all is working great but what i am having problems with is inserting a url in the same  field  as vidID it will look like this in the database hxxp://xxx.mysitehere.com/index.php?vid=vidID  hope you guys know what im talking about im having a hard time explaining it sorry.

<?php
$host="xxxxx";
$username="xxxxxxx";
$password="xxxxxxx";
$db_name="xxxxxxx";
$tbl_name="xxxxxxx";
$message =  strtoupper(trim($_REQUEST['message']));
$sender = strtoupper(trim($_REQUEST['sender']));
$email = strtolower(trim($_REQUEST['email']));
$vidID =$_REQUEST['vidID'];
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="INSERT INTO $tbl_name(message,sender,email,vidID)VALUES('$message','$sender', '$email', '$vidID')";
$result=mysql_query($sql);
?>

Link to comment
https://forums.phpfreaks.com/topic/251710-adding-a-url/
Share on other sites

Are you asking why the link starts with hxxp://?

 

To answer that, is people out there that do hxxp:// versus any proper protocol like http://,https,etc... to show that it's link but hide that it is a link for bots or chats.

 

I for one do not this at all.

 

If it's you that are pasting the links as hxxp in this forum..not sure why are doing that.

 

I'm not sure where you are getting this data from, but you can run these through a case insensitive string replace function to change hxxp to http.

 

//list of urls
$url_array = array("hxxps://xxx.mysitehere.com/index.php?vid=vidID", "hxxps://mysitehere.com/index.php?vid=vidID","hxxp://xxx.mysitehere.com/index.php?vid=vidID", "hxxp://mysitehere.com/index.php?vid=vidID");

//replace function
function replaceHxxp($url){
$url = str_ireplace(array("hxxps://xxx.","hxxps://","hxxp://xxx.","hxxp://"), array("https://www.","https://","http://www.","http://"), trim($url)); 
return $url;
}

//looping urls through the function
foreach($url_array as $urls){
echo replaceHxxp($urls) . "<br />";
}

 

results of the urls would now be:

https://www.mysitehere.com/index.php?vid=vidID

https://mysitehere.com/index.php?vid=vidID

http://www.mysitehere.com/index.php?vid=vidID

http://mysitehere.com/index.php?vid=vidID

 

You should also look into sanitizing/escaping any data inserted into mysql

Some reading material for you.

http://php.net/manual/en/function.mysql-real-escape-string.php

http://php.net/manual/en/function.urlencode.php

http://www.php.net/manual/en/function.urldecode.php

http://www.php.net/manual/en/function.rawurlencode.php

http://www.php.net/manual/en/function.rawurldecode.php

Link to comment
https://forums.phpfreaks.com/topic/251710-adding-a-url/#findComment-1290900
Share on other sites

Well after writing that function, which is useful for what I did it for.

I do believe you would like to append your sites url to an assigned vidid.

 

It's better to just on displaying to append your sites domain/location just on display.

Less data in database, may switch domains or the file locations.

 

Really is no need to do that unless you yourself will be doing it your self from different domains.

 

but can do this if what i said is correct.

$vidID = "hxxp://xxx.mysitehere.com/index.php?vid=" . $_REQUEST['vidID'];

Link to comment
https://forums.phpfreaks.com/topic/251710-adding-a-url/#findComment-1290902
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.