PDA

View Full Version : Pass Hidden Fields/values via URL



RealEstate
02-14-2006, 04:08 AM
Hey guys,

Short version of what's below...I wanna know how to pass hidden fields via a URL to a form in a contact us page. All done in plain HTML and non OR related.

If you're brave...read long description below ;)

----------------------------------------------------

This is not related to OR or PHP, CGI, etc.
This is just plain HTML for begginers.

Lets say I have a website with 100 pages and 1 page as Contact US.
The Contact Us page has a form visitors can submit.

Each of the 100 pages contains a particular product. Each of this 100 pages
will contain a link to the Contact Us.

Visitor is on Page5 which talks about Shoes. Vistor clicks on Contact Us link.
Visitor fills form. I receive form content.

On the email that I receive I also want to receive info telling me that the visitor was looking at Shoes right before submitting the contact form.

What I want is the hidden field "Shoes" to be passed to the contact us page and submitted to me along with the contact form information filled.

I think the terminology of what I'm looking for is "Passing Hidden Fields via Link". or Query String.

I want to do it in easy plain HTML. No fancy programming or javascript.

Something like this might work but I'm clueless
<a href="http://example.com/contact.html?Shoes">
Click here for Contact Us
</a>

The above info was found here:
http://www.bontragercgi.com/Track_Your_Contact_Form_Use.html


I also found this in the microsoft site, but it might be for asp.net
http://www.contoso.com/listwidgets.aspx?category=basic&price=100


Much appreciated as always.

ian_ok
02-14-2006, 05:11 AM
How about something like:
link from shoes page is:
w ww.site.com/contactus.html#shoes
so then you need to tell the contact us form to collect the data from the URL - will check this out and get back to you later.

Why not php? Would be very easy....still I've not tested it!

ian_ok
02-14-2006, 08:21 AM
It's php based for sending the email, but that also keeps your email safe:

Your shoes website:

<form action="http://www.site.com/contactus.html" method="post" >

<input name="page" type="hidden" value="shoes">
<input name="GO" type="submit" value="Submit">
</form>

Your contact us form:

<?php
$page = $_POST['page'];
?>
<form action="www.costaandsierra.com/1.php" method="post" >
<input name="" type="text" value="<?php echo $_POST[page]; ?>">
</form>

Ian

RealEstate
02-14-2006, 12:58 PM
Hey Ian,

Why not PHP...because I don't wanna have to worry if the
hosting account has php and all that stuff.

Because I wanna be able to reuse it rather quickly by simply
modifying the end tail of the links. Since there could be many many.

I wanted to keep it as simple as possible and as easy to modify as possible.
So I was hoping if had 100 shoes,
<a href="http://example.com/contact.html?Shoes">
Click here for Contact Us
</a>

<a href="http://example.com/contact.html?Shoes2">
Click here for Contact Us
</a>

Shoes3.....Shoes100...etc

If I can't find the easy fast way, I'm probably gonna have to look into
your coding, thanks man.

ian_ok
02-14-2006, 01:49 PM
Hey Ian,

Why not PHP...because I don't wanna have to worry if the
hosting account has php and all that stuff.
If your host doesn't offer PHP then they aren't 'TRUE' hosting company and therfore stay away from them.

Don't forget for this line:
<input name="" type="text" value="<?php echo $_POST[page]; ?>">

You can make it hidden, this was just to show you how it would pass the value.

RealEstate
02-16-2006, 01:16 AM
Anybody besides Ian have any suggestions?

RealEstate
02-16-2006, 04:31 AM
The only thing with your code is that is
One form going to another Form (in the contact page).

I need links to go the contact page.
The links need to carry the hidden fields to the contact page form.

CanariasData
02-16-2006, 08:43 AM
Hello RealEstate,

what speaks against calling your pages .php instead of .htm(l)?
I dont think it will be possible to pass the variables with html pages.
I did the same as you want using simple links like:

link on the shoe 1 page:
<a href="http://example.com/contact.php?ID=shoes1">
Click here for Contact Us
</a>

in the contact form you add a field:
Refering Page:
<input name="shoe" type="text" id="shoe" value="<?php
if(!$_GET['ID']){
echo('');
}
else{
echo ("".$_GET['ID']."");
}
?>" size="12" maxlength="20">

the field in your form can be hidden of course!

This way you just need to add ?ID=shoe1 or 2 or 3 or n to your links.

kindest regards,
Gregor

ian_ok
02-17-2006, 01:19 PM
I like it Gregor but I have 1 resevation, would you not lose SEO as each contact us page would be classed as a different URL by the SE's - One way round it is to block Se in the robots.txt and or add no index for the contact us page.

Ian

CanariasData
02-17-2006, 04:02 PM
Hola Ian,

never had any troubles with SE's in generall! And why should it be bad if SE would think your site has 1000 pages instead ot only 10 (in case you'd have 990 shoes!) And beside that, the contact us page normaly holds not to much intresting content (texts) for SE's

For me this solution always worked without any problems.

regards from the canary's to peninsula
Gregor

ian_ok
02-20-2006, 11:29 AM
Hola Ian,

never had any troubles with SE's in generall! And why should it be bad if SE would think your site has 1000 pages instead ot only 10 (in case you'd have 990 shoes!) And beside that, the contact us page normaly holds not to much intresting content (texts) for SE's

For me this solution always worked without any problems.

regards from the canary's to peninsula
GregorHi Gregor, Having 990 contact us pages would hurt your site unless it's got a very good PR to start off with. Would be classed duplicate content. I'd block it in the robots.txt just to be sure.....just my opinion which could be wrong or not very good!

Salud