Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to save hidden value of form in MySQL- please help 1

Status
Not open for further replies.

sbayter

IS-IT--Management
Nov 14, 2002
95
CO
Hi,
I relatively new to PHP and I am having some trouble with a form sending a value to MySQL.
I need to send the value in "$ref" to the database.
The value of ref comes from the URL like this:

when I click submit it says "Column 'CLIENTS' cannot be null" and does not save it in the db.
I know the problem is in
value=&quot;<?php $ref;?> but I don't know what I'm missing.
The form is like this:

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;<?php echo ($PHP_SELF); ?>&quot;>

<input name=&quot;submit&quot; type=submit class=button value=&quot;Submit&quot;>
<input type=&quot;hidden&quot; name=&quot;CLIENTS&quot; value=&quot;<?php $ref;?>&quot;>
<input type=&quot;hidden&quot; name=&quot;MM_insert&quot; value=&quot;form2&quot;>
</center>
</form>

Thanks for your help, sbayter
 
Try referencing the value as $_GET['ref'].

The PHP runtime configuration setting that causes new programmers the most problems is &quot;register_globals&quot;. In older versions of PHP, this was set to &quot;on&quot;, in newer, it defaults to &quot;off&quot;.

If &quot;register_globals&quot; is set to &quot;on&quot;, then you can reference that variable as $ref. If register_globals is set to &quot;off&quot;, you must reference it as $_GET['ref'].

The PHP online manual recommends leaving register_globals set to &quot;off&quot; (
I recommend referencing your input variables as $_POST, $_GET, $_SESSION, $_FILES, etc, because it makes your code more maintainable. Six months from now you may not remember how a value got into $ref. But it's pretty obvious where the value in $_GET['ref'] came from.

For more information on the superglobal arrays, please read here: Want the best answers? Ask the best questions: TANSTAAFL!
 
&quot;Try referencing the value as $_GET['ref']&quot;

I tried this with GET, POST, and FILES but it gives me the same error.
Any other suggestions?
Thanks, sbayter
 
never mind, It's working now.
Thanks sleipnir214 !!! sbayter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top