NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Driving me bonkers (simple PHP)

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 05-22-2006, 07:59 PM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Aug 2005
Location: Leeds, UK
Posts: 263
noswad is an unknown quantity at this point
 



Driving me bonkers (simple PHP)


Hello.

Is it possible to take the end of a link e.g. .com/?id=123 and insert the '123' into the into a field of a registration page using PHP so I can log which users have referred others.

Thanks.
__________________
Michael McIntyre - Fan site for the super funny UK comedian Michael McIntyre
Last edited by noswad; 05-25-2006 at 10:08 PM.
noswad is offline  
Old 05-23-2006, 10:37 AM   #2 (permalink)
NamePros Member
 
xemiterx's Avatar
Join Date: Dec 2003
Location: Oregon
Posts: 110
xemiterx is on a distinguished road
 



It is both possible and easy. If you had x.com/page.php?id=xx and

PHP Code:
echo '<input type=hidden name=id value=' $_GET['id'] . '>'
????: NamePros.com http://www.namepros.com/programming/201199-driving-me-bonkers-simple-php.html
somewhere on page.php then you would have a hidden form element containing the id of the referer.
xemiterx is offline  
Old 05-23-2006, 05:25 PM THREAD STARTER               #3 (permalink)
NamePros Regular
Join Date: Aug 2005
Location: Leeds, UK
Posts: 263
noswad is an unknown quantity at this point
 



Thanks v much!
__________________
Michael McIntyre - Fan site for the super funny UK comedian Michael McIntyre
noswad is offline  
Old 05-25-2006, 09:44 PM THREAD STARTER               #4 (permalink)
NamePros Regular
Join Date: Aug 2005
Location: Leeds, UK
Posts: 263
noswad is an unknown quantity at this point
 



Hi

I got this working at first by changing the code a little bit but for some reason I can't get it to work any more.

Could anyone help me please? Its driving me nuts.

David

P.S. The field doesn't have to be hidden although I would prefer it to be
__________________
Michael McIntyre - Fan site for the super funny UK comedian Michael McIntyre
Last edited by noswad; 05-25-2006 at 09:53 PM.
noswad is offline  
Old 05-25-2006, 10:12 PM   #5 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Merged your threads

Really isn't that hard either.. and would suggest the same as xemiterx.

PHP Code:
<?php
????: NamePros.com http://www.namepros.com/showthread.php?t=201199

$id 
intval($_GET['id']);

echo 
'<input type="hidden" name="id" value="' $id '">';  

?>
What did you change? ^^ Should work just fine.
Eric is offline  
Old 05-26-2006, 05:32 AM THREAD STARTER               #6 (permalink)
NamePros Regular
Join Date: Aug 2005
Location: Leeds, UK
Posts: 263
noswad is an unknown quantity at this point
 



Excellent thanks. One little problem though -

If register.php?id=[text] the form is submitting '0' but if the id=[numbers] it's submitting correctly.

Any clues?

Thanks again
__________________
Michael McIntyre - Fan site for the super funny UK comedian Michael McIntyre
Last edited by noswad; 05-26-2006 at 05:40 AM.
noswad is offline  
Old 05-26-2006, 11:26 AM   #7 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Ok, I was assuming the 'id' was just numerical, well, you could do the following:

PHP Code:
<?php

$id 
trim($_GET['id']);

if(
preg_match("/([^a-z0-9]+)/i"$id))
{
    die(
'Invalid ID');
}

echo 
'<input type="hidden" name="id" value="' $id '">';  
????: NamePros.com http://www.namepros.com/showthread.php?t=201199

?>
Eric is offline  
Old 05-26-2006, 01:58 PM THREAD STARTER               #8 (permalink)
NamePros Regular
Join Date: Aug 2005
Location: Leeds, UK
Posts: 263
noswad is an unknown quantity at this point
 



Thanks v much. V grateful.
__________________
Michael McIntyre - Fan site for the super funny UK comedian Michael McIntyre
noswad is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 05:18 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger