Reputation: 9273
i send an HTML email with a form and a button like this:
<form action="http://myurl/index.php" method="post">
<input type="hidden" name="testing" value="123456">
<button class="btn" type="submit">SEND</button>
</form>
then in my index.php page i read the testing
variable, in this way:
echo $_POST['testing'];
but i can't read the variable and give me this:
Notice: Undefined index: testing
there is a way to send a variabile from an html mail to a php page?
Upvotes: 0
Views: 354
Reputation: 777
What happens when you replace:
<button class="btn" type="submit">SEND</button>
With
<input type="submit" value="Send" />
I realize you are probably styling it given that you have a class statement but you can still style an input type="submit" easily enough. I ran into issues posting variables using the object.
Also, FWIW, you don't need to specify the full URL in the action. In fact, you should probably do the following to safeguard your self against XSS attacks:
<form action="<? echo htmlentities('/path/to/index.php'); ?>" method="post">
Upvotes: 0
Reputation: 86
Emails don't play well with a lot of fairly standard html. In this case, I'd use something like this:
<a href="http://myurl/index.php?testing=123456">Submit</a>
And then style your anchor to look like a button. Then on your php side, use this to make sure the variable gets there:
print_r($_GET);
Upvotes: 1
Reputation: 6167
Oh. Got that Email Part now.
Most Mail-Programs won't do POST requests, for security/privacy reasons. Use GET here:
in HTML:
<a href="http://myurl/index.php?testing=123456">SEND</a>
and in PHP:
echo $_GET['testing']
Of course the data is visible in that case - but that's the entire point.
Upvotes: 2