Search code examples
phpformsget

how to send url with get method


i have a form like this:

<form method="get" action="sample.php">
    <input type="text" name="url">
    <input type="submit" value="send">
</form>

when i sumbit form with an url(like https://google.com) my link is:

site.com/sample.php?url=https%3A%2F%2Fgoogle.com

but i want send Formed url like this (without https://):

site.com/sample.php?url=google.com

how i can do this?


Solution

  • Using jquery you can replace http:// or https:// with nothing before submit:

    $("form").submit(function(){
       var $input = $(this).find("input[name=url]");
       var cleanValue = $input.val().replace("http://","").replace("https://","");
       $input.val(cleanValue);
    });