1shotoffers Posted April 18, 2010 Share Posted April 18, 2010 I am looking to populate existing URLs on a page with an "affiliate id" which would be entered by user on a form In other words.....the user would enter their ID name or number in a form and upon submit it would change all base URLs on the page to URL including their id http://www.thesite.com/?e= changes to......... http://www.thesite.com/?e=users_input Can someone help me out with code to accomplish this? Link to comment https://forums.phpfreaks.com/topic/198920-code-to-populate-id-within-url-on-form-submit/ Share on other sites More sharing options...
Jax2 Posted April 18, 2010 Share Posted April 18, 2010 Without seeing your current code, I'm not sure how you've written it, but with the form, just use a single $_POST at the top, such as: $id=$_POST['ID']; and then for all links, simply add the ID to them: i.e. "... this.php?id=".$id.""; and it will work Link to comment https://forums.phpfreaks.com/topic/198920-code-to-populate-id-within-url-on-form-submit/#findComment-1044150 Share on other sites More sharing options...
Jax2 Posted April 18, 2010 Share Posted April 18, 2010 You could even do it all on one page. For example: <?php if (isset($_POST['submit'])) { $id=$_POST['id']; INSERT REST OF PAGE HERE (including all links) } ELSE IF (!$_POST['id']) { INSERT FORM HERE - method: post, action: same page (php self) <input type="text" name="id" size="10"> <input type='submit" name="submit" value="Go!"> } That way, it will only show them the links once they've entered their affiliate ID and you don't need multiple pages to do it all on ... It will just start with the form and then it will go to the links once they submit the form... Link to comment https://forums.phpfreaks.com/topic/198920-code-to-populate-id-within-url-on-form-submit/#findComment-1044153 Share on other sites More sharing options...
1shotoffers Posted April 18, 2010 Author Share Posted April 18, 2010 Thanks! the first option worked great for what I needed! Link to comment https://forums.phpfreaks.com/topic/198920-code-to-populate-id-within-url-on-form-submit/#findComment-1044161 Share on other sites More sharing options...
SaMike Posted April 18, 2010 Share Posted April 18, 2010 Why not just use cookie for it? $_COOKIE['refid'] = $id; Link to comment https://forums.phpfreaks.com/topic/198920-code-to-populate-id-within-url-on-form-submit/#findComment-1044216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.