text box to address bar script

  gregsickle 18:27 02 Apr 05
Locked

Hi, I run a small site and was wondering if there was any way in which i could have a box on my site where i users could type in a word, press submit and that word would come up in the address bar.

For example if the user typed in 'cat' to the address bar, the script would put "click here" into the address bar.

Any responces would be much appriciated

Thanks

  Nelmon2k 19:47 02 Apr 05

It depends if your site is php enabled. If it is you could to it. If it isnt I'm not sure if it can be.

  Nelmon2k 19:49 02 Apr 05

sorry. I misread what it was saying. I dont think it can be done by entering information into the address bar. It can be done however by entering information into a box on the main page if your server is php enabled. It can probably be done if you are asp enabled instead

  gregsickle 21:15 02 Apr 05

yes my server is php enabled. Could you tell me how to do it?

Thanks

  gregsickle 21:15 02 Apr 05

yes my server is php enabled. Could you tell me how to do it?

Thanks

  harristweed 13:25 04 Apr 05

You may need to remove the spaces from the URL
This MUST be at the top of the page with NO WHITE SPACE. The page must have a .php extention.




<?php

$add=$_POST["add"];



if($add<>"")

{

$goto="http: // mysite.com/ ".$add.".htm";

header("Location:$goto");

}

?>

<form name="form1" <?php echo "FORM

ACTION=\"$_SERVER[PHP_SELF]\"
METHOD=\"POST\" "; ?>


<p>

<input type="text" name="add">

</p>

<p>


<input type="submit" name="Submit" value="Submit">

</p>


</form>

  harristweed 13:29 04 Apr 05

The php must be at the top.
From:

<form name="form1" <?php echo "FORM.....

Can go anywhere

  gregsickle 20:21 04 Apr 05

Thank you for the script. I have tried installing it but i have not yet succeded. How could i install it into ms frontpage.

Sorry. I am a bit new to php.

  harristweed 01:12 05 Apr 05

I dont use Frontpage, but...

You must be able to somehow / edit see the html code.

At the very top of the document

before...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"click here">
<html>
<head>


etc.

put this ....remove theblank lines


<?php

$add=$_POST["add"];

if($add<>"")

{

$goto="http: // mysite.co.uk/ ".$add.".html"; // you might need to correct this

header("Location:$goto");

}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN".......


then the form in the < body >
section

<form name="form1" <?php echo "FORM

ACTION=\"$_SERVER[PHP_SELF]\" METHOD=\"POST\" "; ?>

<p>

<input type="text" name="add">

</p>

<p>

<input type="submit" name="Submit" value="Submit">

</p>

</form>


save page as pagename.php

That should then work....

This thread is now locked and can not be replied to.

Amazon Fire HD 8 review: A brilliant combination of function and value – with one massive caveat

1995-2015: How technology has changed the world in 20 years

How to create an introvert-friendly workplace

Apple Watch Series 2 review | Apple Watch 2 review: New Apple Watch is faster, brighter,…