/    Sign up×
Community /Pin to ProfileBookmark

Pre-fill automatically a form field with part of the URL

Hello,

I am developing a site with Dreamweaver CS3 and have a little knowledge of HTML.
I need a solution for the following:
Visitors can come to my site through a referrer for ex: [url]www.domain.com/?ref=cesar017[/url]
The referrer’s information (cesar017) should be prefilled automatically in a form field on another page than the index page. This means the visitor first can look around on the other pages of the site and then go to the page with the form. I don’t use a database at this moment, I only want a certain field automatically prefilled with the referrer’s info from the URL for ex : <input type= hidden -or text- name= partner id= partner value= “”/> In this case the field should have the value=”cesar017”
I understood this can best be solved with PHP and sessions, but I nearly don’t know anything about this and Dreamweaver has not automated this function.
Can somebody help me with this script (how, where * head – body section *…)

In advance thanks for your help

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@scragarSep 09.2009 — I don't think for something like this sessions are the best idea, sessions are best if you don't want the user to edit the information, there is no reason to want something like this here.

Add this anywhere before your HTML begins to start the cookie.
[code=php]if(isset($_GET['ref']))
setcookie('referrer', $_GET['ref'], time()+3600);[/code]

And then use it:
[code=php]<input type="text" name="referrer" value="<?php
echo htmlspecialchars($_COOKIE['referrer']);
?>" />[/code]
Copy linkTweet thisAlerts:
@belperauthorOct 28.2009 — Hello,

First of all my apologies for the delay in my replay (I have been unable to post these last months for personal reasons. Thanks for understanding).

The solution proposed by Scragar is working and is the best one for my needs.

Thank you very much for helping me.
×

Success!

Help @belper spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...