SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2010
    Location
    ONS
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can we have control over what we send in a form data?

    Can we have control over what we send in a form data?

    I want to do a thing with $_GET['search'] URL variables, so,

    Code HTML4Strict:
    <form name="index.php" method="get"> 
    <input type="text" size="30px" name="search" value="" /> 
    <input type="submit" value="Submit" /> 
    </form>

    This will send data to the url variables
    and o index.php, I can get the URL Variable (search) to work with it.
    Everything was working fine.

    But today I seen an error when I searched http://www.google.com (which is with http://).

    Suddenly I came to the error page that this page doesn't exist.
    How it could be possible.
    How to make everything searchable including http://

    Note: If you have not understood what I want to do, then in short, I want something like this,

    http://www.localhost.com/?s=http://www.google.com
    But I am getting error in this, but
    http://www.localhost.com/?s=www.google.com
    this works fine.

    Example In HTML, I want to something like,
    Code HTML4Strict:
    <form name="index.php" method="get"> 
    <input type="text" size="30px" name="search" value="<?php str_replace('http://', '', $value_entered_by_user); ?>" /> 
    <input type="submit" value="Submit" /> 
    </form>
    Thanks.

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why is your form name index.php? That should be action me thinks.

    Where did localhost.com/?s come from? The field is named 'search' so I'd expect the request to go to localhost.com/?search, unless your script is redirecting you there? In which case you may need to urlencode the value.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,784
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by cranial-bore View Post
    In which case you may need to urlencode the value.
    The default for forms is urlencoded - no additional code should be needed to set it to that. You could always try adding an enctype= to the form tag though to see if changing that makes any difference.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <form name="index.php" method="get">

    you haven't specified where the form data is to be sent to.




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •