Page 1 of 1
PHP forms
Posted: Tue Dec 02, 2014 12:49 am
by Paul-sea
Hi
I am a relative newbie to PHP
Although I am familiar with creating web forms in PHP, could someone suggest a method for the following:
I have three web pages (page 1, page 2, page 3) , each page relates to a different subject all the pages can access a contact form, I need to add a subject line to the form which can be populated by a variable from page 1, 2 or 3 dependant on which page the form is accessed from.
I realize I could generate 3 individual forms to do this, but my page count is likely to increase significantly in the future so it makes sense to use variables to populate the subject line.
Please advise!
Paul C
Re: PHP forms
Posted: Tue Dec 02, 2014 1:42 am
by requinix
It depends mostly on what you already have. Are those three pages and the contact form already written?
Re: PHP forms
Posted: Tue Dec 02, 2014 2:45 am
by Paul-sea
Hi requinix
Nothing written as yet so ..... clean sheet..... I have created contact forms on a couple of web sites in the past, but this is slightly different. essentially each page will have a "contact us for more info" button to open the form. The actual form php I already have and can adapt, its just the best method to pass a string from the chosen page to the form. I am in no way a programmer or coder but I am willing to learn what I need to in order to achieve this!!
Please advise
Thanks!!

Re: PHP forms
Posted: Tue Dec 02, 2014 6:44 am
by Celauran
Where is the page content coming from? Is it CMS-driven or is it static? Passing a variable to the form is trivial, but the value still needs to be obtained somewhere.
Re: PHP forms
Posted: Tue Dec 02, 2014 6:54 am
by Paul-sea
Hi Celauran
Page will be static.
The string I need to pass to the form will be a product name.
Thanks
Re: PHP forms
Posted: Tue Dec 02, 2014 7:10 am
by Celauran
If the page is static and you're just going to include() the form, you may as well just hardcode the variable value into each individual page.
Re: PHP forms
Posted: Tue Dec 02, 2014 7:27 am
by Paul-sea
Hi Celauran
Yes understood on that, so each page will have a statement which goes along the lines of declaring $product="a unique product" (the $product value changes on each page). the advice I'm after is which method I need to employ to pass $product to the form. As stated I'm not a programmer, I just need to be pushed in the right direction
Regards
PaulC
Re: PHP forms
Posted: Tue Dec 02, 2014 8:12 am
by Celauran
How are you including the form in the page?
Re: PHP forms
Posted: Tue Dec 02, 2014 9:03 am
by Paul-sea
Hi Celauran
the form will be a separate page, only called if required by the user. and yes I've just had the lightbulb moment that says each page could be designed with the form embedded, which would negate the requirement to pass info between the web pages and a separate form.... but if I had to have a stand alone form, what would I need to do?
Regards
PaulC
Re: PHP forms
Posted: Tue Dec 02, 2014 9:19 am
by Celauran
You won't need to do anything special to make the variable available to the form, just be sure to declare if before including the form.
Re: PHP forms
Posted: Tue Dec 02, 2014 9:52 am
by Paul-sea
Celauran
Thanks, I'll go do some homework now....
Regards
Paul C