![]() |
help with referral tracking code
Hey guys,
I'm slowly trying to learn some php, I can mostly just follow along tutorials, as I haven't been able to memorize a lot of the rules and things yet. I'd like to have a way for people to refer other people to fill out this form on my site. Basically how I plan for it to work, is a user enters their info into the form, submits it, info is appended to csv file. I open csv file and assign a unique id # based on the position in the csv file. Then I'd like them to be able to refer other users based on that id #. And if someone fills out the form using that other person's referral id #, it records that on the csv file. So I have some questions with going about this... Lets say someone's referral id # is 123. Can I give them a link that says mysite.com/apply.php?refid=123 and then insert the code below into /apply.php, or is there another step? Code:
<?php session_start();
Does the code accomplish those things? And are there any problems with the way the codes written? Any suggestions or help is appreciated :) |
Quote:
You are concentrating on the referrer, why? he is not on your site nor is he doing anything on your site at present. It's the current user you need to track. Especially if you have things she can or should do on the site. When the new user fills out the form he enters or does not enter a referrer's number. You should write all form info to the file immediately, including the referrer number. That's all you need. P.S. This is just for your information: Learn how PHP talks to MySQL (a database) or one of your choosing. It's simple and you can get info from it much easier then a cvs file. |
I'm starting an online advertising network.
I want to be able to reward people for referring others to my network. So lets say user1 signs up, gets their refid #, then posts it on their website. user2 follows that link, and check out my site. closes it out, leaves the computer, and comes back later in the day and signs up. I don't want user2 to have to fill in user1's refid #. I'd like user1's refid # to be sent to the csv file with the rest of the form automatically. I'm not sure why the code above isn't accomplishing that :( Could you help me out? Or tell me if I'm confused with something. I think integrating mysql is a little beyond my level right now. But in the future as I learn more I may try it out. Edit: This is the full code: Code:
<?php session_start();Warning: Cannot modify header information - headers already sent by (output started at /home/vvm/public_html/publishers/apply/index.php:18) in /home/vvm/public_html/publishers/apply/index.php on line 84 |
If user2 goes to your site because of a link on user1's web site and leaves you have no information on him. How are you going to know when he comes back? Do you have a login page? Is there anyway you can store his info if he(user2) does not fill out the form.
If you log everyone that comes to your site from user1 that file will get large and how do you know when to delete them? Say user2 comes in from user1 and leaves; comes back 5 times over a three month period and then fills out the form. See what I mean? I think you can reward user1 when a person follows his link to your page and you can give out bigger rewards if user2 fills in the form at that time, but keeping records on people that enter via a link and tying them to that link will get out of hand. FYI Session variables are destroyed when a session ends or times out. Before starting an online advertising network learn how to use a database!! |
@Sunfighter I want it to save the session info (refid) for a limited amount of time. I was under the impression that the session ID would expire when the person closes their browser or clears their history?
All I want is if user2 follows user1's link, and user2 fills out the form, then user1's refid is appended to the entry into the csv file. And if user2 views a different page on my site right after following user1's link, it should store user1's refid for a short time so if user2 goes back to the form and fills it out, it still adds user1's refid. I tried editing my code some, but I'm getting this error still: PHP Warning: Cannot modify header information - headers already sent by (output started at /home/vvm/public_html/publishers/apply/index.php:21) in /home/vvm/public_html/publishers/apply/index.php on line 88 Also, can anyone help me in deleting the commas, enters, =, -, and other special characters that users can enter that ruin csv files? Code:
<?php |
First let me ask you a question, does the site your putting this on give you access to mysql?
If user2 comes into your site with address that ends in ?refid=123 or some other number this code checks it and sets a cookie OR it see if as cookie exists and if yes reads it and puts into a session variable. PHP Code:
, are you? |
Yes, I do have access to mysql, though I'm not too familiar with mysql.
I figured the csv file would be simpler, and at least be functional until I can develop a better solution. Yes, I am having trouble with the code I published :o Could you help me with integrating your cookie script into my code so its functional? |
Replace your first php section with what I gave you.
IE does not understand the submit button. In your form use a hidden field. I like Code:
<input type="hidden" name="msoft" value="junk">Then use this line in your evaluation code: Code:
if(isset($_POST["msoft"]) && $_POST["msoft"] == 'junk')Code:
if($_POST['pubformsubmit'] == "Submit")Here's an updated but not fully correct page: PHP Code:
|
Thanks for the help.
I'll start on researching validating the input forms more once I get the refid thing working right. I updated the code with your changes. There are no errors, but its not writing the refid # to the csv file? Any idea why? Code:
<?php |
Quote:
Add this line in form under the first hidden input: Code:
<input type="hidden" id="refid" name="refid" value="<?php echo $value; ?>">Code:
$value = '';Code:
$_SESSION["rewards"] = ''; |
It seems to only work when I go to the page with the refid link, then visit another page and go back to the form.
So if you go straight to the refid link and fill out the form, it doesn't record the refid into the csv. I tried messing around with the code but nothing I did seems to fix it :( Could you help me with this? |
If you call the form page like this http://www.formpage.php?refid=235
Then you have an id of 235 and that should be written to the file. If you click on the page or call it with http://www.formpage.php then you did not come from a referencer page and there is no ID. |
If you go to the page from example.com/apply/index.php?refid=123
And you fill out the form, it will not record refid 123. However, if you go to example.com/apply/index.php?refid=123 And then leave the page, and then go back to example.com/apply Then it will record refid 123 in the csv when you submit the form. I'm not sure why its working like that, is there something I missed? I tried adding this code below to the form, and adding $refid to the list of fwritebut it did not change anything. Code:
<input type="hidden" id="refid" name="refid" value="<?php echo $refid; ?>" />PHP Code:
Code:
<!DOCTYPE html>Also I looked up Regex like you suggested :eek: Do you think this code would remove everything except letters numbers _ and - I think those are all the important characters. Could you tell me where in my code I should place this? PHP Code:
Also, thank you for all the help sunfighter. I greatly appreciate it! |
njfail there is no need to continue this on the forms. I sent you email through the site it's in your "USERCP" The tag to get there is located at the top of the page. Mail sent this PM.
|
| All times are GMT +1. The time now is 04:59 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.