tags:

views:

532

answers:

3

I have am trying to pass the value of a label into the php.

how should i do that? My HTML looks like:

<form action='unsubscribe.php' method='get'>
  <label for='[email protected]'>[email protected]</label>
  <input type='submit' value='Unsubscribe me'>
</form>

How can i get the value of this label passed into my unsubscribe.php?

Best Zeeshan

+1  A: 

You will need to create a hidden input, then use JavaScript to populate the hidden input prior to posting the form so that unsubscribe.php can retrieve it via $_POST.

Andrew Hare
I need to actually answer the question before I edit it :PNice answer +1
Robert Greiner
i can not use javascript here. because this html is being open in outlook .. i am sending a mail for this. but is it possible to disable the input box and then submit its value to php??
Zeeshan Rang
+4  A: 

By using the <input type="hidden" ... /> tag:

<form action='unsubscribe.php' method='get'>
<input type="hidden" name="email" value="[email protected]" />
<input type='submit' value='Unsubscribe me'>
</form>

If you are going to use <form method="get" ...> you might as well just make a url:

<a href="http://www.example.org/unsubscribe.php?email=zee%40example.org"&gt;Unsubscribe&lt;/a&gt;

Or with php (note the urlencode):

print("<a href=\"http://www.example.org/unsubscribe.php?email=".urlencode("[email protected]")."\"&gt;Unsubscribe&lt;/a&gt;");
danamlund
A: 

Why not when composing the link for the e-mail, append the e-mail address you're sending it to in the unsubscribe url?

<a href="http://example.com/[email protected]"&gt;Unsubscribe Me!</a>
S Pangborn