Author Topic: Send Current Page URL With Form Submit  (Read 10061 times)

Offline snapchris

  • Newbie
  • *
  • Posts: 17
  • Karma: +1/-0
    • View Profile
Send Current Page URL With Form Submit
« 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

Offline Gordon Taylor

  • Global Moderator
  • Full Member
  • *****
  • Posts: 150
  • Karma: +28/-1
    • View Profile
    • Natural Handcrafted Soaps
Re: Send Current Page URL With Form Submit
« Reply #1 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.

Offline snapchris

  • Newbie
  • *
  • Posts: 17
  • Karma: +1/-0
    • View Profile
Re: Send Current Page URL With Form Submit
« Reply #2 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.

« Last Edit: June 23, 2015, 03:51:15 PM by snapchris »

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5772
  • Karma: +274/-2
    • View Profile
Re: Send Current Page URL With Form Submit
« Reply #3 on: June 24, 2015, 05:04:06 AM »
I think you can not run php code in this way

Offline Gordon Taylor

  • Global Moderator
  • Full Member
  • *****
  • Posts: 150
  • Karma: +28/-1
    • View Profile
    • Natural Handcrafted Soaps
Re: Send Current Page URL With Form Submit
« Reply #4 on: June 24, 2015, 07:11:21 AM »
Correct Basara, php can't be used within the form tags.

Offline snapchris

  • Newbie
  • *
  • Posts: 17
  • Karma: +1/-0
    • View Profile
Re: Send Current Page URL With Form Submit
« Reply #5 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.

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5772
  • Karma: +274/-2
    • View Profile
Re: Send Current Page URL With Form Submit
« Reply #6 on: July 01, 2015, 03:59:20 AM »
Thank you for posting solution

Offline Gordon Taylor

  • Global Moderator
  • Full Member
  • *****
  • Posts: 150
  • Karma: +28/-1
    • View Profile
    • Natural Handcrafted Soaps
Re: Send Current Page URL With Form Submit
« Reply #7 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!

Offline snapchris

  • Newbie
  • *
  • Posts: 17
  • Karma: +1/-0
    • View Profile
Re: Send Current Page URL With Form Submit
« Reply #8 on: July 01, 2015, 09:56:32 PM »
Thanks! You're Welcome!

 

Powered by SMFPacks Social Login Mod