Input Value Default

If I have this code (here on http://debate.forumify.com/page.php?id=10):

[php]


[/php]

How would I go about using a token to define the default value of the input box based on the URL? For example, if the URL is

http://debate.forumify.com/page.php?id=10&ref=Ratburntro44

How would I make it so that with that URL the input box would have a default value of “Ratburntro44”?

[php]

[/php]

Pretty self-explanatory, I hope?

Thank you, sorry I literally started learning PHP five minutes before I asked this, exclusively for this purpose, yet all the tutorials I could find on it didn’t work.

Except, I just tried that, and it doesn’t work. If it makes a difference, the method for the form is post, and I can’t possibly change it because of the other input boxes.

Hmm…I can’t see why it wouldn’t work. Let me explain what’s going on.

Let’s say you have an URL like this: http://www.example.com/?foo=bar&baz=bot

Notice everything after the question mark? Those are GET variables, and they are referenced in PHP code by accessing the $_GET superglobal array. So for instance, if we want to get the value of the ‘foo’ GET variable, we get to it like this:

[php]
echo $_GET[‘foo’] // bar
[/php]

The only reason I can think that my example wouldn’t work, you might not have PHP short tags enabled on your server, (which would be a bit weird, but on that chance, try this:

[php]

[/php]

Still doesn’t work. I don’t own this server, so I don’t know what it has enabled. As I said, it has post method, I don’t know if that effects it. Anyways, thanks for the help.

Could I get you to post:

  1. The exact URL you’re using to get to the page with the form on it.
  2. The complete code for the form.

I double checked my code example, and it’s working for me in a basic case.

  1. http://debate.forumify.com/page.php?id=10 is the standard URL
    I use http://debate.forumify.com/page.php?id=10&ref=Hi when attempting to test the code.
  2. The current full code for the form is as follows.

[php]


<form id=“register”

method=“get” action=“register.php?action=register” onsubmit="this.register.disabled=true;if(process_form

(this)){return true;}else{this.register.disabled=false;return false;}">

		<div class="forminfo">
				<h3>Important 

information

Registration will grant you access to a number of

features and capabilities otherwise unavailable. These functions include the ability to edit and delete

posts, design your own signature that accompanies your posts and much more. In addition, by registering you are agreeing to the set of rules listed here. If you have any questions

regarding this forum you should ask an administrator.


Below is

a form you must fill out in order to register. Once you are registered you should visit your profile and

review the different settings you can change. The fields below only make up a small part of all the settings

you can alter in your profile.



			<legend>Please enter a username between 2 and 25 characters long</legend>


			<div class="infldset">
					<input 

type=“hidden” name=“form_sent” value=“1” />

Username
<br

/>


<legend>Please enter and confirm your chosen password</legend>
				<div 

class=“infldset”>
<label

class=“conl”>Password
<input type=“password” name=“req_password1” size=“16”

maxlength=“16” />

Confirm

password

				<p class="clearb">Passwords can be between 4 and 16 characters long. 

Passwords are case sensitive.


<div class="inform">
			<fieldset>
Image Verification
		<img src=ran.php><br />
					<label 

class=“conl”>Image Text
<input type=“text” name=“req_image” size=“16” maxlength=“16”

/>

Please copy the text in

the image to the text box above


			<fieldset>
Enter a valid e-mail address
		<label><strong>E-mail</strong><br />


Referrer

Referrer

Set

your localisation options

		<label>Timezone: For the forum to display times correctly you must select your local 

timezone.

				<option value="-12">-12</option>
				

	<option value="-11">-11</option>
-10 -09
				<option value="-8.5">-8.5</option>
				

	<option value="-8">-08 PST</option>
-07 MST <option value="-6"

selected=“selected”>-06 CST

-05 EST
-04 AST

					<option value="-3.5">-3.5</option>
			

		<option value="-3">-03 ADT</option>
-02 -

01
00 GMT

				<option value="1">+01 CET</option>
				

	<option value="2">+02</option>
						<option 

value=“3”>+03
+03.5

					<option value="4">+04</option>
				

	<option value="4.5">+04.5</option>
+05 <option

value=“5.5”>+05.5
<option

value=“6”>+06
+06.5

					<option value="7">+07</option>
				

	<option value="8">+08</option>
						<option 

value=“9”>+09
+09.5

					<option value="10">+10</option>
				

	<option value="10.5">+10.5</option>
+11 <option

value=“11.5”>+11.5
<option

value=“12”>+12
+13

				<option value="14">+14</option>

		<fieldset>
				<legend>Set your privacy 

options

<p>Select whether you want your e-mail address to be viewable to other users or not and if you want 

other users to be able to send you e-mail via the forum (form e-mail) or not.

	<div class="rbox">
						<label><input 

type=“radio” name=“email_setting” value=“0” />Display your e-mail address.

			<label><input type="radio" name="email_setting" value="1" checked="checked" 

/>Hide your e-mail address but allow form e-mail.

Hide your e-mail address and disallow form e-

mail.

This option sets whether the forum should "remember" you between visits. If enabled, you will not have to

login every time you visit the forum. You will be logged in automatically. Recommended.

		<div class="rbox">

Save username and password

between visits.

<input

type=“submit” name=“register” value=“Register” />


[/php]

Hmm…interesting. When I go to your page, it’s not just not working. What’s happening is that the PHP code is being written in to the text box ‘raw’, that is, it’s not being interpreted. I copy and pasted your code in to my local server and tried it, and everything works properly though.

That makes me wonder if PHP is enabled on the page correctly. Are there other examples of PHP code on the page that are working? If not, try something experimental…where you currently have the “Important Info” h3 tag, replace it with this:

[php]<?= "

Important Info

" ?>[/php]

Just to see what happens. If you see that code rendered raw instead of your heading just like you had before, then there’s something wrong with your PHP configuration.

It renders as Important Info" ?>
What should the PHP configuration be? I don’t have enough control in the server to change it, but I can contact the owner of the server.

Honestly, I can’t be sure exactly how to fix the problem without being pretty familiar with your server set up. How are you actually going about editing the page? It seems like for whatever reason, PHP code is being stripped out of the final version of the page, so it might actually be an intentional configuration thing too. Your best bet at this point will be to show what you’ve done to the server admin. There’s nothing wrong with your code, so they’ll need to help you make sure things are configured properly.

I have to go to “Custom Pages” in administration tools, and then the only part I am allowed to edit on the page is the part within the box saying “Registration”. It does appear to be intentional, so I’m going to contact the server admin.

Sponsor our Newsletter | Privacy Policy | Terms of Service