passing parameters or page being viewed "id/name" with emails

Issues related to forms.
Post Reply
rgsmiths
 
 
Posts: 22
Joined: Thu Mar 16, 2017 12:47 am
Contact:

passing parameters or page being viewed "id/name" with emails

Post by rgsmiths » Sat Oct 28, 2017 9:05 pm

What I am doing is using one Comment Form, on multiple pages, and would like to know what page was active when user clicked on Comment Form to send me comments...
If I include ?x=Index or ?x=Page10 to the links line of the Comment Form, is there a way to see this ?x=Page10 etc appended like: www.site.com/c/comment.php?x=Page10 in messages rcvd?

If there is a better way I would be open to it...
ie if I could append to the sent data a field or something via submit button's object html ...

Anyone have suggestions?

Tnx Roy

WWBman
 
 
Posts: 742
Joined: Fri Jan 08, 2010 6:10 pm

Re: passing parameters or page being viewed "id/name" with emails

Post by WWBman » Sat Oct 28, 2017 9:53 pm

If you have a form on each page (not a master object) you can just add a hidden field in each form and specify the page name in the value field. This will then be included in the email.

rgsmiths
 
 
Posts: 22
Joined: Thu Mar 16, 2017 12:47 am
Contact:

Re: passing parameters or page being viewed "id/name" with emails

Post by rgsmiths » Sat Oct 28, 2017 10:42 pm

Thanks for the reply...

Yes could do that ... but that would require Comment1.php comment2.php... forms for each page...
want one Comments.php linked to by each page... since have many pages

could I use FormData.Append() somehow..?...

I just do not find yet a way to easily make each page with hyperlink to Comments.php send
a page identifier with the email message..

WWBman
 
 
Posts: 742
Joined: Fri Jan 08, 2010 6:10 pm

Re: passing parameters or page being viewed "id/name" with emails

Post by WWBman » Sat Oct 28, 2017 10:58 pm

In your first post you say you have one comment form on multiple pages.
So on each separate page do you have a comment form?
If so, then you can add the hidden field to each comment form.
If not then I must have misunderstood how you have organized the pages.

WWBman
 
 
Posts: 742
Joined: Fri Jan 08, 2010 6:10 pm

Re: passing parameters or page being viewed "id/name" with emails

Post by WWBman » Sat Oct 28, 2017 11:24 pm

If you have just one page with the comment form and multiple pages linking to that page then you can do the following:
Each link will have to be a full web address (External Web Address) which contains the page name:
E.g. http://www.webaddress/comments.php/?page=abcde

Then add a hidden field to the comments form that contains <?php echo $_GET['page'] ?>

I think that should work.

EDIT:
Actually you can use Page in the Project (instead of External Web Address) and add the page=abcde in URL Parameters for Internal Links.

rgsmiths
 
 
Posts: 22
Joined: Thu Mar 16, 2017 12:47 am
Contact:

Re: passing parameters or page being viewed "id/name" with emails

Post by rgsmiths » Sun Oct 29, 2017 2:23 am

I think the suggestion to add <?php echo $_GET['page'] ?>
to the hidden field would work if I could get it entered correctly...
Here are my tries
in the form options...
The tab "Hidden Fields"
has Add... then Name... I put in Page
then Value... I put in <?php echo $_GET['page'] ?>
but this gives error message of

PHPMailer error: Message body empty

dito error message with form object html, at inside tag

<input type="hidden" name="Page" value="<?php echo $_GET['page'] ?>"

so... not sure what to try next...
but appreciate the tip...

User avatar
Pablo
 
Posts: 19684
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: passing parameters or page being viewed "id/name" with emails

Post by Pablo » Sun Oct 29, 2017 8:19 am

I don't think that <?php echo $_GET['page'] ?>
is directly related to the error message:
PHPMailer error: Message body empty
Does it work when you remove the hidden field?

WWBman
 
 
Posts: 742
Joined: Fri Jan 08, 2010 6:10 pm

Re: passing parameters or page being viewed "id/name" with emails

Post by WWBman » Sun Oct 29, 2017 8:27 am

Yeah, you're probably right Pablo.
It seems to work for me.
Just to double check; the hidden field should look like this:
Did you enter the ID field?
Image
free web hosting images
And the link:
Image
free web hosting images

rgsmiths
 
 
Posts: 22
Joined: Thu Mar 16, 2017 12:47 am
Contact:

Re: passing parameters or page being viewed "id/name" with emails

Post by rgsmiths » Sun Oct 29, 2017 12:55 pm

Hooray it works now....
you were right Pablo... err msg not related to adding the hidden field...
I found that somehow the body content was not right because when
I added some html to page and then deleted it per my tries to get this working
that there must have been something left behind...
looked at source and seemed ok but when put in data and submitted got the err msg...
so recreated the form, put in the hidden field per your last messages and it works now...

Thank you both for your patient and clear help...
This will really help me keep comments straight... and it is an easy fix...

Roy

WWBman
 
 
Posts: 742
Joined: Fri Jan 08, 2010 6:10 pm

Re: passing parameters or page being viewed "id/name" with emails

Post by WWBman » Sun Oct 29, 2017 2:20 pm

Just one more thing Pablo!
Do you think it's worth allowing for code injection attacks by using something like the following?

<?php echo strip_tags($_GET['page']) ?>

User avatar
Pablo
 
Posts: 19684
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: passing parameters or page being viewed "id/name" with emails

Post by Pablo » Sun Oct 29, 2017 4:00 pm

I do not think that is useful in this case, because the content of hidden fields can be modified via the browser anyway.

WWBman
 
 
Posts: 742
Joined: Fri Jan 08, 2010 6:10 pm

Re: passing parameters or page being viewed "id/name" with emails

Post by WWBman » Sun Oct 29, 2017 4:18 pm

Ah right, OK thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests