Jump to content

PHP page forward with a form


Travist6983

Recommended Posts

ok i am trying to create city pages such as birmingham.php that all it does is forward to the search result for birmingham we are a real estate company that is trying to get some better SEO with all our surrounding citys... our search results page land on listings.php

 

i have done this to our footer of each page with this form action

 

<form name="Birmingham" action="listings.php" method="post">
                <input type="hidden" name="searchType" value="custom">
  				<input type="hidden" name="newSearch" value="true">
  				<input type="hidden" name="table" value="rs">
  				<input type="hidden" name="city" value="2192">
  				<input type="hidden" name="beforeListPrice" value="0">
  				<input type="hidden" name="afterListPrice" value="any">
  				<input type="hidden" name="featuredOnly" value="false">
</form>	
<a href="javascript:void[0];" onclick="document.forms['Birmingham'].submit(); return false;">Birmingham</a>

 

is it possible to use this form action in like a PHP header forward?

<?php
header("location: javascript:void[0]; onclick="document.forms['Birmingham'].submit(); return false;"");
?>

 

Any suggestions on this would be a great help

Thank You

Link to comment
https://forums.phpfreaks.com/topic/170705-php-page-forward-with-a-form/
Share on other sites

Javascript is a CLIENT SIDE scripting language and cannot interact with PHP like this. You'd need to use this to redirect..

 

Birmingham.php:

<?php
header('Location: '.$_SERVER['SERVER_NAME'].'/seach.php?city=birmingham');
?>

Like so.. Which'll automatically redirect them.

<?php
header("location: javascript:void[0]; onclick="document.forms['Birmingham'].submit(); return false;"");
?>

 

No it isn't your headers can only be http response headers (http://www.w3.org/Protocols/HTTP/Object_Headers.html) or custom headers starting with X-

Javascript is a CLIENT SIDE scripting language and cannot interact with PHP like this. You'd need to use this to redirect..

 

Birmingham.php:

<?php
header('Location: '.$_SERVER['SERVER_NAME'].'/seach.php?city=birmingham');
?>

Like so.. Which'll automatically redirect them.

 

Search engines don't like redirects.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.