AbanteCart Community

AbanteCart Development => Customization help => Topic started by: snapchris on June 23, 2015, 02:43:50 AM

Title: Send Current Page URL With Form Submit
Post by: snapchris on June 23, 2015, 02:43:50 AM
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
Title: Re: Send Current Page URL With Form Submit
Post by: Gordon Taylor on June 23, 2015, 08:09:14 AM
We could use a little more information such as:

Screenshot of the from and the code your using to insert that field.
Title: Re: Send Current Page URL With Form Submit
Post by: snapchris on June 23, 2015, 11:01:42 AM
<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.

(http://s7.postimg.org/7vwuim11n/screen1.png)
Title: Re: Send Current Page URL With Form Submit
Post by: Basara on June 24, 2015, 05:04:06 AM
I think you can not run php code in this way
Title: Re: Send Current Page URL With Form Submit
Post by: Gordon Taylor on June 24, 2015, 07:11:21 AM
Correct Basara, php can't be used within the form tags.
Title: Re: Send Current Page URL With Form Submit
Post by: 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.
Title: Re: Send Current Page URL With Form Submit
Post by: Basara on July 01, 2015, 03:59:20 AM
Thank you for posting solution
Title: Re: Send Current Page URL With Form Submit
Post by: Gordon Taylor on July 01, 2015, 07:25:36 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!
Title: Re: Send Current Page URL With Form Submit
Post by: snapchris on July 01, 2015, 09:56:32 PM
Thanks! You're Welcome!