WCHost
07-31-2004, 12:59 PM
Hello,
How to get the Referral URL work? i have searched many sites but it doesnt teach how to get it work...
example URL
http://www.example.com/ref.php?id=xxx
I think is like that...maybe I am wrong
So when someone input that links, in the "id" box, it will appears "xxx"
Can anyone teach me?
Thanks :bawling:
So when someone input that links, in the "id" box, it will appears "xxx"
I don't understand what you're trying to do. Please elaborate, so I can help you.
Are you referring to the php navigation? If so, here's some code for you.
<?php
if(!isset($id)) {
echo "This user doesn't exist.\n<META http-equiv=\"Refresh\" content=\"5;URL=ref.php\">";
} else {
switch ($id) {
case "xxx":
// use an include function or echo to display text
break;
default:
// this used in case the id doesn't equal xxx
// use an include function or echo to display text
break;
}
}
?>
That above would most definitely need customizing but, I am guessing that is what you are referring to. If this is not, I apologize. :)
Good Day.
Designz
07-31-2004, 04:37 PM
if you are wanting a referal system, first you would have to have a membership system running first.
This is how it would be structured..
Registration
\/
Member info in database, referal link given out
\/
Page has sql/php coding which then adds +1 in the users referal row.
Something like this for the last bit
<?php
include("connect.php"); //make sure we connect to the database first
$user = $_GET['user'];
if(!$user){
//echo out site normally
} else {
$sql = mysql_query("SELECT * FROM members WHERE user='$user' LIMIT 1");
$row = mysql_fetch_array($sql);
$referal = $row['users_referals']; //Get whats in that field
$referaladd = $referal +1; //I am not sure on this as ive not used math operators in php before, but basically your adding one onto whats in the db
$add = mysql_query("UPDATE members SET users_referals = '$referaladd' WHERE user = '$user'"); //Update the db with the users referals
echo "You were refered by $user";
//echo out rest of the site
}
?>
I stress the above may not work as i just typed it out on the fly, but it sort of tells you of my concept i was trying to get across...
Regards,
Phil :)
However, if you want the referral id "xxx" to be displayed in a text box you would have to do document.form.value= $id
it would have to be a mix btw javascript and php as i would just make the php into the code where it doesnt even display who the referral is so they cant remove it....otherwise name the box readonly
Car-Partout.com
07-31-2004, 07:15 PM
jdk, that's not so. Read designs code again. He's already done all that, and there's no reason to use any javascript whatsoever in that. ;)
You are correct I read the question wrong not the code. He is correct.
w3bdesign
07-31-2004, 10:57 PM
Please remember to avoid using global variables as $id.
Use $_GET['id']; instead, like posted above. This saves you from troubles later on.
Designz
08-01-2004, 09:29 AM
Originally posted by w3bdesign
Please remember to avoid using global variables as $id.
Use $_GET['id']; instead, like posted above. This saves you from troubles later on.
Or you could use the following, to save typing superglobals ..
if (!ini_get("register_globals")){
foreach ($_REQUEST as $k=>$v){
if (!isset($GLOBALS[$k])){
${$k}=$v;
} } }
..With thanks to barrywien for supplying me this code a few days ago :D
Just saves time and u only need it right at the top of each page.
Phil :)