I have 2 versions of this code... one WITH Sessions and one without. The one without the sessions being used works just fine but the one with sessions is having problems.
I have a url:
www.example.com/register.php?refid=1234567
I am trying to get the refid from the url and save it to a variable. I want to do this when a "Submit" button is clicked to register after filling a form out.
If I have code that says
Code:
if(isset($_POST['submit']))
{
//RUN THIS CODE
}
when I fill the form out and click submit, the page refreshes and the url becomes:
www.example.com/register.php
This works:
Code:
if(!empty($_GET["refid"])){
$refered_by = $_GET['refid'];
}
if(isset($_POST['submit']))
{
//RUN THIS CODE
}
but this does not:
Code:
if(isset($_POST['submit']))
{
if(!empty($_GET["refid"])){
$refered_by = $_GET['refid'];
}
}
Even with the first example that DOES work... if I try to reference that $refered_by variable inside the code block that validates the submit button was clicked... it tells me that the $_GET['refid'] is undefined.
Is there any reason the ?ref=123456 is being removed from the url when the user clicks the submit/sign up button? Is this causing $_GET['refid'] to be undefined? Lastly... even if that's the case, why isn't $refered_by saving the variable if I establish it before the submit code block?
Any help will be appreciated so I can not only fix the code but also understand what is happening here.