Jump to content

undo auto populate text field input


useroo

Recommended Posts

I have 2 PHP issues to solve and so far no answer to either.

The first one:
In an old directory script i have some script section that populates the URL form submission field with the http:// - unfortunately this interfers with the new common https:// that can not be added as it ends up doing http://https://

So i would like to stop the auto population of http:// in either or both of 2 below script segments .. but i am just not sure how i do this correctly, can anyone in this forum clear this up for me??

function ParseURL($url) {
$url = trim($url);
	  //if (strpos($url, '.')<1) { return false;  }
  
  // check if empty 
  $len = strlen($url);
  if ($len<3) { return false;  }
  
  if (strcmp("http://", substr($url, 0, 7)) !== 0) {
      $url = "http://" . $url;
  }
	  $url_stuff = parse_url($url);
  if (!isset($url_stuff["path"])) {  $url = $url . "/";  }
	  return $url;
}

GetHTML"
as

 if (strpos($nueva,“http://”)=== FALSE) {
$nueva = “http://” . $urlc . $nueva;
}

and a bit further down in


“function GetAllHTML”

The other question i am not as to how far it is actually a PHP issue.
After installing a SSL certificate on one of my older websites all static HTML pages display just fine in all browsers - but all the PHP generated pages dispaly crooked. My host said i need to refresh ALL pages of the site .. but did not feel it's his job to tell me how i can do that, so, how to "refresh" all PHP generated files??

Link to comment
Share on other sites

I suppose the easiest way would to be completely strip off the http:// or https:// and then add it back again, something like this:

 

if (strpos($nueva,“http://”)=== FALSE) {
$nueva = “http://” . $urlc . $nueva;
}

 

REPLACE THAT CODE ABOVE WITH THE FOLLOWING:

$nueva = 'https://'.preg_replace('/http[s]*:\/\/.*/','',$nueva);

So it now doesn't matter if http or https is present they will be stripped out completely and then you can add whatever you want at the beginning (in this case i added https)

Link to comment
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.