URL Parameters to Autofill Form

Status
Not open for further replies.

Blasteh

big tits
Apr 3, 2013
1,156
521
Hi,
I’ve been looking around on the web, but I can’t seem to find out how to do it. I’m looking to do something like example.org/ref/Blasteh, then when they visit that, it’d fill out the “referrer” option in the form. Essentially the base URL is something like example.com/register?reg_ref=Blasteh, but with the URL rewrite it’s as stated above. My issue is that when I do the parameters, it doesn’t want to seem to fill out that part of the form.

PHP:
<input type="text" name="reg_ref" id="ref" value="Referrer"/></td>
</tr>
 

MayoMayn

BestDev
Oct 18, 2016
1,423
683
PHP:
<input type="text" name="reg_ref" id="ref" value="Referrer" value="<?=$_GET['reg_ref']?>" />
You need to set the "value" attribute, which will set the initial value of the input field.

JavaScript equivalent:
PHP:
document.querySelector('#ref').defaultValue = 'Sentinel';
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Please provide the code you are currently using in full. A form doesn't get filled out magically, so I assume you have some PHP or JavaScript already?
 

Blasteh

big tits
Apr 3, 2013
1,156
521
PHP:
<input type="text" name="reg_ref" id="ref" value="Referrer" value="<?=$_GET['reg_ref']?>" />
You need to set the "value" attribute, which will set the initial value of the input field.

JavaScript equivalent:
PHP:
document.querySelector('#ref').defaultValue = 'Sentinel';
Tried this, didn't seem to work.

PHP:
<form method="post">      
                <div class="msg regi">Ref</div>
                <input type="text" name="reg_ref" id="ref" value="<?php $_GET['reg_ref']?>" /><br/><center>
            </form>
 

Berk

berkibap#4233
Developer
Oct 17, 2015
863
190
Tried this, didn't seem to work.

PHP:
<form method="post">     
                <div class="msg regi">Ref</div>
                <input type="text" name="reg_ref" id="ref" value="<?php $_GET['reg_ref']?>" /><br/><center>
            </form>
Can try jQuery aswell,
Code:
$('#ref').attr('value', '<?= $_GET['reg_ref'];?>');
Put this into your document.ready.
 

MayoMayn

BestDev
Oct 18, 2016
1,423
683
Tried this, didn't seem to work.

PHP:
<form method="post">
                <div class="msg regi">Ref</div>
                <input type="text" name="reg_ref" id="ref" value="<?php $_GET['reg_ref']?>" /><br/><center>
            </form>
Ofc it doesn't work you forgot to include echo before the array..
I'm using the shorthand PHP syntax.
Just do exactly what I wrote and it'll work FailFish

PHP:
value="<?=$_GET['reg_ref']?>"
 
Can try jQuery aswell,
Code:
$('#ref').attr('value', '<?= $_GET['reg_ref'];?>');
Put this into your document.ready.
You basically just converted my JS equivalent to JQuery....
 

Blasteh

big tits
Apr 3, 2013
1,156
521
Ofc it doesn't work you forgot to include echo before the array..
I'm using the shorthand PHP syntax.
Just do exactly what I wrote and it'll work FailFish

PHP:
value="<?=$_GET['reg_ref']?>"
 

You basically just converted my JS equivalent to JQuery....
That's what I did at first, it still didn't work m8.
 

JynX

Posting Freak
Feb 6, 2016
710
438
Programmatically it should work, so I don't know what you're doing wrong tbh.
After speaking with Blasteh it appears the $_GET variable is not being set at all thus why it's not echoing anything. If I remember correctly, this was a problem with RevCMS and how it functioned.
 

Blasteh

big tits
Apr 3, 2013
1,156
521
After speaking with Blasteh it appears the $_GET variable is not being set at all thus why it's not echoing anything. If I remember correctly, this was a problem with RevCMS and how it functioned.
Alex fixed our $_GET variable after you providing a fix and it now works without rewriting.
No wonder there's problems if he's using Rev LUL
Also, never knew RevCMS looked like this FeelsBadMan
You must be registered for see images attach

Issue has been solved.

/closethread
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
After speaking with Blasteh it appears the $_GET variable is not being set at all thus why it's not echoing anything. If I remember correctly, this was a problem with RevCMS and how it functioned.
Yeah, next time I'll give a warning for this. Actions such as these pull away proper content and solutions from the forum.

Also, moved to Habbo Help & Support. If it's Rev, it belongs there.
 
Status
Not open for further replies.

Users who are viewing this thread

Top