Jump to content

define variable in form.


IwnfuM

Recommended Posts

Hi , how I can save something into form?

I mean , insert something in variable  and than insert it into value in the form so when i send the form the value will be send too.

I also want that it will be can not change.

for example :

<input name="email" value="[email protected]"/>

but this example can be change if you insert something else.

 

thanks , Mor.

 

Link to comment
https://forums.phpfreaks.com/topic/213410-define-variable-in-form/
Share on other sites

If you don't want the user to see the variable then use a HTML hidden input inside the form tag, the data will be sent with the form but the user won't see it like so:

 

<input type="hidden" name="myvariable" value="182" />

 

Be aware that any form input can be changed (even hidden) if the user really wanted to, for example by using the Firebug extension of Firefox.

Just be aware that it is possible for a user to view the source page of the form and send any data they like - even for hidden fields. So, always validate the sent data before using it.

 

In this case since you are sending an email address I would suggest saving the email addresses to a database or creating an include file with an array defined with the email addresses. In the form page put the id of the email address. Then in the processing page use the ID to get the actual email address. You should never include an email address in a web page (visible or not) unless you want that page to be picked up by spam bots.

You can do this - and the hidden field's value will change based on whatever value you set for @formVariable.  Is that what you mean?

------------------------

<?php

$formVariable = "This Value";

?>

<form name="frmSample" action="frmSubmit.php" method="post">

<input type="hidden" name="hdnVariable" value="<?php print $formVariable; ?>">

<input type="submit">

</form>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.