tags:

views:

203

answers:

3

I use the $_GET function to pull a value with php from the url (http:..../index.html?variable=value), basic stuff. However, I need to use that value in my form.

Typically, I would set

<?php echo 'value="'.$variable.'"' ; ?>

or something to that effect. However, I can't use php inside my form using the editor I'm working with.

Can I set a value in the form without using PHP in my form? If so, how?

Edit: with the CMS editor I'm using you can't store php code to the server. (I'm using FCKeditor. The same used by Dubral). This is a security measure all CMS's use even Wordpress. Basically I want to send/set the value in the form with php. Similar to how javascript does it: document.form.field.value

+2  A: 

That looks completely valid to me. If you're using something like Dreamweaver, which is the only valid interpretation I can come up with, use a plain text editor instead of the editor you currently use. Problem solved.

There might be a more specific fix if you were to say what editor you're using, but since you don't, this is the best I can do. Just use Notepad or whatever.

Matchu
An editor without code view? Sounds more like Word to me :-)
jeroen
that works but with the CMS editor I'm using you can't store php code to the server. (I'm using FCKeditor. The same used by Dubral). This is a security measure all CMS's use even Wordpress.Basically I want to send/set the value in the form with php. Similar to how javascript does it: document.form.field.value
dcp3450
Ah. If this is HTML saved to the database, you pretty much can't use PHP in it, due to the typical implementation of echoing rather than evaluating. (By the way, echo. Don't evaluate.) You will need a more clever solution than the existing CMS.
Matchu
A: 

You can set the value without php, but it has to be static value hardcorcoded in the html itself. For dynamic pages you have to use some programming language.

Mikulas Dite
+1  A: 

The best way to set default values (ie pre-existing values) within an HTML form is as you mentioned in your question value="'.$variable.'"'.

If you are unable to use markup like that, then you may be able to use javascript (whether referencing a secondary file/feed using AJAX, or using the same variable echoing technique) to replace the values in the specific fields after the page has loaded.

ie

<script language="javascript">
document.form[0].name.value = "<?php echo $name; ?>";
</script>
Lucanos
pulled the variable with php then set it using javascript replaceing the value like you did. Thanks
dcp3450