You can check the $_POST using var_dump($_POST); to see what's in it. If its empty, it's not receiving post, which indicates that it is receiving a $_GET instead. Did you modify the form action there as well, or was that always post?
Also, this hasn't a thing to do with Mysql. Moving to PHP forum.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Many thanks, once again.
Firstly, let me apologise for posting in the wrong forum. I do get confused when the php objective is to populate the mysql database.
Secondly, sorry I misled you with $email. That was actually declared lower down the list (I only showed part of the list to save space.
However, I have obviously confused myself because this is not the problem.
The script is a double opt-in email catcher.
i.e. the subscriber fills in the form and the script sends out an email to the subscriber to verify the correct email address. The subscriber then clicks on a link in the email which then adds the data to the database.
The problem is NOT sending out the email, it is AFTER the subscriber clicks on the link. This is the link that is sent out to the subscriber:
PHP Code:
//////// SEND SUBSCRIBE VALIDATION EMAIL
$mail_body = "Please DO NOT reply to this email. It is an unattended mailbox.\n\nTo validate your email address, please click the following link:\n\nhttp://countrymusic.org.uk/calendar/register-exec.php?email=$from&emailcount=$emailcount&act=$active&action=subscribe&fname=$fname&surname=$surname&country=$country&year=$year&m=$hashed";
I must admit, I don't really know when to use POST and when to use GET.
Is there a rule of thumb ???.
When the data is passed in a querystring (that is after a ? as part of a web address) then you read it using $_GET.
If the data is being passed from a form that has method="POST" then you read it using $_POST.
Note that in both cases you should validate the content received looks reasonable before moving it to another field for subsequent processing by your code - preferably validation but at least sanitize the data before moving it. That way you keep the tainted fields separated from the untainted ones.
Thanks very much for your explanation. This makes it a lot clearer.
I changed all my POSTs and GETs some years ago when I read that REQUEST was the best.
Recently I have read that REQUEST shouldn't be used so I am changing it all back. Slowly.
Thanks again.
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
Recently I have read that REQUEST shouldn't be used so I am changing it all back.
One reason $_REQUEST shouldn't be used is that using it means that you have no control over whether the information is passed in $_POST, $_GET or $_COOKIE as it consolidates all three. In most cases you only want the info to come from one of those three places and so not looking for it in the other two places makes your code more secure.
I have never seen anywhere recommending using REQUEST - even 10 years ago all the references I saw were recommending against using it.
$_POST when your request is post, $_GET when you're request is get.
In HTML world, $_POST when your form has an action="post", $_GET when its passed through a querystring.
$_REQUEST is another one of those "brainchild" things that zend did, like register_globals and magic_quotes. Newer versions of PHP can control these variables (at perdir level) in PHP 5.3+. The ultimate fallback is still to variables_order which is by default EGPCS, or ENV, GET, POST, COOKIE, and finally SERVER. This is clearly a big problem as now you cannot tell which method provided what AND it's overridden in the order from left to right.
At the very minimum $_REQUEST should be manually overwritten as a merge of $_POST and $_GET, where $_POST overrides $_GET. My suggestion is to never use it.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php