Send data type into textbox to addressbar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • schroed9er
    New Member
    • Aug 2012
    • 1

    Send data type into textbox to addressbar

    I'm making a form that has a text box and submit button. Whatever is typed into the text box I want it to go to the address bar. For example if someone types 'name' in the text box and they press submit it will take them to the page on my website:

    http://www.mywebsite.c om/name

    Can anyone help?

    Thanks.
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    We don't write code for people here, but since this is so short that explaining it will probably take longer, here's a simple code to do what you're asking

    Code:
    <?php
    
    if($_GET['submit']) header("location: http://www.mywebsite.com/".$_GET['page_name'])
    
    ?>
    <html>
     <body>
      <form action="" method="get">
       <input type="text" name="page_name" value="" />
       <input type="submit" name="submit" value="Go" />
      </form>
     </body>
    </html>
    Any questions?

    Dan

    Comment

    • ariful alam
      New Member
      • Jan 2011
      • 185

      #3
      Why you need a PHP code for this? you can do this using JavaScript. here is the code:
      Code:
      <script language='javascript' type='text/javascript'>
      	function redirect(user)
      	{
      		var location='http://localhost/';
      
      		window.location = location+user;
      	}
      </script>
      
      <input type='text' size='30' id='txtbox'/>
      <input type='button' value='click' onclick='javascript:redirect(document.getElementById("txtbox").value)'/>

      Comment

      Working...