<form method="get" id="download" action="getvideo.php">
<h1 class="form-download-heading">Youtube Downloader</h1>
<input type="text" name="videoid" id="videoid" class="inputtext" size="40" />
<input class="styled-button-11" type="submit" name="type" id="type" value="Download" />
</form>
<!-- php code in getvideo.php -->
<?php
// removing the http and https from input
$string = $_POST['videoid'];
$words = array('HTTP', 'HTTPS');
$replacements = array('', '');
$result = str_replace($words, $replacements, $string);
echo $result;
if(isset($_REQUEST['videoid'])) {
$my_id = $_REQUEST['videoid'];
if(strlen($my_id)>11){
$url = parse_url($my_id);
$my_id = NULL;
if( is_array($url) && count($url)>0 && isset($url['query']) && !empty($url['query']) ){
$parts = explode('&',$url['query']);
if( is_array($parts) && count($parts) > 0 ){
foreach( $parts as $p ){
$pattern = '/^v\=/';
if( preg_match($pattern, $p) ){
$my_id = preg_replace($pattern,'',$p);
break;
}
}
}
if( !$my_id ){
echo '<p>No video id passed in</p>';
exit;
}
}else{
echo '<p>Invalid url</p>';
exit;
}
}
} else {
echo '<p>No video id passed in</p>';
exit;
}
if(isset($_REQUEST['type'])) {
$my_type = $_REQUEST['type'];
} else {
$my_type = 'redirect';
}
if(isset($_REQUEST['debug'])) {
$debug = TRUE;
} else {
$debug = FALSE;
}
if ($my_type == 'Download') {
?>
I am trying to remove the input fields text, when someone enters an url to my input value, I need to remove the HTTP or HTTPS from it, if both are available in the links. when am entering the url in input, the http is again rendering in output after submitting the form.
</div>
use str_replace() function to replace the entered string
<?php
echo str_replace("world","Peter","Hello world!");
?>
In this example, we search for the string "Hello World!", find the value "world" and then replace the value with "Peter".
same replace "http" with blank space