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="a@s.d"/>

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

 

thanks , Mor.

 

Link to comment
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.