| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jun 2006
Posts: 44
|
php query string
Hi, I have a page with a php form which when submitted sends the form details as an email (which works absolutely fine). However there are a number of routes to this page and I would like to use a query string to pass a variable from the previous page so that I can add this information to the emailed details. The link I'm using is: href="downloads-form.php?doc=project_plan" The php code that I use to create the email is a s follows: Code:
The problem I have is that the variable doc returns as Array('doc') in the email rather than project_plan. I've tried lots of ways of doing this such as using just $doc rather than $_GET('doc') but then nothing is returned. I'm sure this is simple, any ideas what I'm doing wrong? |
|
|
|
|
|
#5 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,919
|
Is the email construction in the immediate next page or is there a form page in between? If there is a form in between has it got a hidden field to carry the contents of $doc through? |
|
|
|
#7 (permalink) |
|
Registered User
Join Date: Jun 2006
Posts: 44
|
stickmus, I just tried that but get this error: Parse error: parse error, unexpected '(', expecting '}'... max h (a mint sauce fan eh?!), how would I retrieve the variable before I write it into the message variable? Something like: $doc = $_GET('doc'); and then just: $body.="Download: $doc\n"; I have tried this with no luck... |
|
|
|
#9 (permalink) | |
|
fucksocks™
Join Date: Jun 2005
Location: in the boosh
Posts: 1,623
|
Quote:
$_GET retrieves from the url string $_POST retrieves from variables sent throught the header (i.e. forms) |
|
|
|
|
#12 (permalink) | |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,919
|
Quote:
Was this relevant? |
|
|
|
|
#13 (permalink) |
|
fucksocks™
Join Date: Jun 2005
Location: in the boosh
Posts: 1,623
|
here you go. http://archive.maxhoy.co.uk/get_and_send/send.html zipped files at : http://archive.maxhoy.co.uk/get_and_send/getandsend.zip |
|
|
|
#14 (permalink) |
|
Registered User
Join Date: Jun 2006
Posts: 44
|
Sorry datahound, trying to do 5 things at once here so not fully on the ball... Thanks for your help Max, still not able to get it working though - am I being totally thick?!! (probably) The php script resides on the same page that the form does, so the form action sends it back to itself and then the script sends it on to the thankyou page if all the conditions are met (form validation etc). Basically it is used so that when a link is clicked to download example documentation from the website it takes you to a form that needs to be filled out. Once submitted, the details are sent to us and an email is sent to the user with a link to the download page. What I want to be able to do is add a line to the details that are sent to us that tells me which document it was that the user wanted to download in the first place. Therefore adding a query string to each link and retrieving this means it can be sent in the email. Here's the whole php: Code:
|
|
|
|
#15 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,919
|
I doesn't matter if it is the same pagename it still has to be held in the form in a hidden field and passed forward for processing with the new vars collected in the form. Unless you are using session vars in which case they are held in the air for use at any time. Try putting this in your form? <input name="doc" type="hidden" id="doc" value="<?php echo"$doc"; ?>"> |
|
![]() |