Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Redirect Help Needed

Featured Replies

Can anyone tell me how to go to a particular page when a submit button is pressed please?

 

For example, I want to be able to type different postcodes into an input field but for them all to go to the same URL plus the postcode e.g.

 

When LL56 4PE is typed into the input field I want it to redirect to www.whatever.com/map#search/LL56 4PE

 

Does that make sense!? Thanks for your help in advance! :)

Can anyone tell me how to go to a particular page when a submit button is pressed please?

 

For example, I want to be able to type different postcodes into an input field but for them all to go to the same URL plus the postcode e.g.

 

When LL56 4PE is typed into the input field I want it to redirect to www.whatever.com/map#search/LL56 4PE

 

Does that make sense!? Thanks for your help in advance! :)

<?php
if(isset($_POST['submit'])){
header("Location:www.whatever.com/map#search/LL56 4PE");
exit();
}
?>

  • Author

<?php
if(isset($_POST['submit'])){
header("Location:www.whatever.com/map#search/LL56 4PE");
exit();
}
?>

 

 

Thanks you for that. However, won't that just take me to LL56 4PE every time? I want whatever postcode the user puts in the input field to be placed at the end of the URL. For example:

 

- If they typed in LL56 1LS into the input field and pressed submit it would go to www.whatever.com/map#search/LL56 1LS

 

- If they typed in LL56 2QZ into the input field and pressed submit it would go to www.whatever.com/map#search/LL56 2QZ

 

...and so on.

  • Author

Actually, seeing as this is now a PHP query...can I move it to the PHP section please? Thank you! :)

It will be more like:

 

<?php
if(isset($_POST['submit'])){
header("Location:www.whatever.com/map#search/$PostCode");
exit();
}
?>

 

Then for the postcode field:

 

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

 

You'll also need to tell the form to GET the postcode:

 

$PostCode = $_GET["PostCode"];

 

Something like this should work, see here for more: http://www.w3schools.com/PHP/php_get.asp

  • Author

Cheers Daz. I've got a feeling I'm not doing it right though!! (The fact it's not working gave it away!)

 

I have 2 pages. The first page has the form:

 


<form action="map.php" method="get">
<input type="text" name="PostCode" />
      	<input type="submit" class="bigButton" />
</form>

 

I then have a PHP file that has the following code in it (nothing else):

 


<?php
$PostCode = $_GET["PostCode"];
if(isset($_POST['submit'])){
header("Location:http://www.whatever.com/map#search/$PostCode");
exit();
}
?>

 

 

Can you (or anyone else) tell me where I'm going wrong please? unknw.gif

 

Thank you! I really need to learn PHP!!

  • Author

This could actually just be done with javascript really if you want to just change the url

 

 

Jay, been trying to get hold of you. Check your email! biggrin.gif

Cheers Daz. I've got a feeling I'm not doing it right though!! (The fact it's not working gave it away!)

 

I have 2 pages. The first page has the form:

 


<form action="map.php" method="get">
<input type="text" name="PostCode" />
      	<input type="submit" class="bigButton" />
</form>

 

I then have a PHP file that has the following code in it (nothing else):

 


<?php
$PostCode = $_GET["PostCode"];
if(isset($_POST['submit'])){
header("Location:http://www.whatever.com/map#search/$PostCode");
exit();
}
?>

 

 

Can you (or anyone else) tell me where I'm going wrong please? unknw.gif

 

Thank you! I really need to learn PHP!!

 

 

try including the PHP inside the same page as the form and switching the form's action to the same page it's on too?

 

What happens exactly, any error messages?

Ah I forgot to say, you need to use either $_GET or $_POST, you're using both. Your form has get as the method, so change the

$_POST['submit']
//to
$_GET['submit']

You should also do some text cleaning, to avoid people putting in random crap

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.