0

I am trying to transfer a variable from the URL into a contact form for saving to a MySQL database but don´t know how to do it correctly. SInce my needs are way above my knowledge in PHP and MySQL I am basically hacking a form plugin for rapidweaver which of course is causing all sorts of problems.

Say I have this url: http://www.example.com/index.php?id=200000

and I want to have the “200000” to show up in the form as the input in one of the fields.

I´ll reveal my naivity and complete lack of PHP knowledge by posting my own suggestion:

<input type="hidden" name="form[item_99]" id="item_99" class="fl-hidden" value="<?php echo @check('item_99','hidden','',id); ?>" />

(never mind the form item is set as hidden)

Of course that transfers “id”, not the value of the “url-variable” id. I tried $_get['id']. It transferred nothing.

Any suggestions?

1 Answer 1

2

Actually, $_GET['id'] should get the job done, and it's weird that it wasn't. Let me test it and post back and example.

EDIT: After testing locally, this code definitely works.

<input type="text" value="<?php echo @$_GET['id'] ?>">
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks. To clarify, this is what I used: <input type="hidden" name="form[item_99]" id="item_99" class="fl-hidden" value="<?php echo @check('item_99','hidden','',$_get['id']); ?>" />
@Rikudo Sennin - i've deleted my answer but as for your comment - $_GET could be as well as $_POST multidimensional - just test it on your own (the same goes for $_COOKIE)
Well it is possible that check(......) returns NULL, which is the reason why you get nothing.
@Jacek_FH Well my comment wasn't 100% accurate. Now that you mention it, there are ways such as name=foo[] that will generate a multidimensional array. But that's about the only method I know.
nope, name[foo]=bar is the way (as in Anders question), and it's very convinient in my opinion (for forms). many frameworks use it as well
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.