Im making an email verification system on PHP in cPanel, and when i press register, it sends an email to me with a link like this "../verified.php?code=1cbb402a59e8ec26dac0", i would need to get the full link and would have to chop it so it leaves me with just the code "1cbb402a59e8ec26dac0" so i can check if the code exists in database and then verify the account.
So from this
../verified.php?code=1cbb402a59e8ec26dac0
To This
"1cbb402a59e8ec26dac0
Purchasing the hostings for the first time fried my brains, so would be thankful if anyone could help me,
2
Answers
For getting the text after the
code:
in the link, you can use the PHP$_GET
function. You can use this code in yourverified.php
to get the text aftercode:
Now the part after the
code=
gets stored in the variableData
.You can change that to your desired variable.
Sometimes even when the
code
is set, it might be empty, so to check that, theempty()
function in PHP can be used.You can add this code to your
verified.php
:Well you have chosen to pass parameters which will be available in the global
$_GET[]
(as opposed to$_POST[]
).So in your verified.php you will need to examine for the presence of $_GET[‘code’] and take the appropriate action.
Using
$code = $_GET['code'];
is very bad as you need to qualify it.At a minimum you would need to…