[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 05-22-2006, 06:59 PM   #1 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Location: Leeds, UK
Posts: 260
70.00 NP$ (Donate)

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.
__________________
C905 - Sony Ericsson mobile phone with an 8 megapixel camera!

Last edited by noswad; 05-25-2006 at 09:08 PM.
noswad is offline  
Old 05-23-2006, 09:37 AM   #2 (permalink)
NamePros Member
 
xemiterx's Avatar
 
Join Date: Dec 2003
Location: Oregon
Posts: 110
203.25 NP$ (Donate)

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'] . '>';
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, 04:25 PM   #3 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Location: Leeds, UK
Posts: 260
70.00 NP$ (Donate)

noswad is an unknown quantity at this point


Thanks v much!
__________________
C905 - Sony Ericsson mobile phone with an 8 megapixel camera!
noswad is offline  
Old 05-25-2006, 08:44 PM   #4 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Location: Leeds, UK
Posts: 260
70.00 NP$ (Donate)

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
__________________
C905 - Sony Ericsson mobile phone with an 8 megapixel camera!

Last edited by noswad; 05-25-2006 at 08:53 PM.
noswad is offline  
Old 05-25-2006, 09:12 PM   #5 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Merged your threads

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

PHP Code:
<?php

$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, 04:32 AM   #6 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Location: Leeds, UK
Posts: 260
70.00 NP$ (Donate)

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
__________________
C905 - Sony Ericsson mobile phone with an 8 megapixel camera!

Last edited by noswad; 05-26-2006 at 04:40 AM.
noswad is offline  
Old 05-26-2006, 10:26 AM   #7 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
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 . '">';  

?>
__________________
Eric is offline  
Old 05-26-2006, 12:58 PM   #8 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Location: Leeds, UK
Posts: 260
70.00 NP$ (Donate)

noswad is an unknown quantity at this point


Thanks v much. V grateful.
__________________
C905 - Sony Ericsson mobile phone with an 8 megapixel camera!
noswad is offline  
Closed Thread


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:22 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85