News:

AbanteCart v1.4.2 is released.

Main Menu

Do you like AbanteCart? Please rate AbanteCart or share your experience with other eCommerce entrepreneurs. Go to Softaculous rating page to add your rating or write a review

Send Current Page URL With Form Submit

Started by snapchris, June 23, 2015, 02:43:50 AM

Previous topic - Next topic

snapchris

Im trying to add a hidden field that sends the current URL of the page that its on along with the rest of the form data.
Ive tried in form manager but it returns nothing. Any help would be greatly appreciated! Thanks

Gordon Taylor

We could use a little more information such as:

Screenshot of the from and the code your using to insert that field.

snapchris

#2
<input type="hidden" name="current_url" value="<?php echo 'http://',$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];?>"  readonly/>

If I add that PHP to the value in Form Manager it send back blank.


Basara

I think you can not run php code in this way

Gordon Taylor

Correct Basara, php can't be used within the form tags.

snapchris

So what I did to get this working is edit hidden.tpl and replace it with this:

<input type="hidden" id="current_url"  name="current_url" value="<?php echo 'http:/domainname.com',$_SERVER['REQUEST_URI'];?>" <?php echo $attr ?> />

Then I changed the Field Name & Display Name in the Forms Manager to "current_url" for the Hidden Field Type
You can replace your domain name in place of "domainname.com"
I dont know how this effects anything else with a hidden field, but I only have that one so this works for me.

Basara


Gordon Taylor

Quote from: snapchris on July 01, 2015, 03:56:23 AM
So what I did to get this working is edit hidden.tpl and replace it with this:

<input type="hidden" id="current_url"  name="current_url" value="<?php echo 'http:/domainname.com',$_SERVER['REQUEST_URI'];?>" <?php echo $attr ?> />

Then I changed the Field Name & Display Name in the Forms Manager to "current_url" for the Hidden Field Type
You can replace your domain name in place of "domainname.com"
I dont know how this effects anything else with a hidden field, but I only have that one so this works for me.

Good job and well solved, thanks!

snapchris


Forum Rules Code of conduct
AbanteCart.com 2010 -