dannybrazil Posted July 27, 2009 Share Posted July 27, 2009 Hello guys few min' ago some kind people helped me with a piece of code : $string = R$100.000,00 ; $result = preg_replace('/[^0-9]+/', '', $string); echo $result; what i wanted to know now is : Is it possible to do this "change" before the form is being uploaded to the data base i mean already to make it replace the "value" in the input ? this is my input: <td> <strong>Preco</strong>:<br /> <input type="text" name="preco" width="20px" onBlur="this.value=formatCurrency(this.value);"> </td> and it will update the database with $R100.00,0 , is it possible to make the update already just numbers? Danny Link to comment https://forums.phpfreaks.com/topic/167636-another-question-regarding-form-variables/ Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 Yes, of course, after being submitted: $preco = $_POST["preco"]; $result = preg_replace('/[^0-9]+/', '', $preco); You would want to validate the data as well and secure it before insertion. Link to comment https://forums.phpfreaks.com/topic/167636-another-question-regarding-form-variables/#findComment-884064 Share on other sites More sharing options...
dannybrazil Posted July 27, 2009 Author Share Posted July 27, 2009 If its after submitting the form how would it update the entry ? i want that the user will see the price as a price format BUT the info/data that will be uploaded to the database AFTER submission with be as a regulat INT type(just numbers) Danny Link to comment https://forums.phpfreaks.com/topic/167636-another-question-regarding-form-variables/#findComment-884085 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 This is of course done AFTER the form has been submitted but BEFORE the data is inserted into the database. Link to comment https://forums.phpfreaks.com/topic/167636-another-question-regarding-form-variables/#findComment-884093 Share on other sites More sharing options...
dannybrazil Posted July 27, 2009 Author Share Posted July 27, 2009 Hmmm.... im kind of lost after submitting the form it goes to the action page right ? where should i add the code you gave me before in order for it to change the info ? Danny Link to comment https://forums.phpfreaks.com/topic/167636-another-question-regarding-form-variables/#findComment-884095 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 Where you handle the form data prior to the insert query. Link to comment https://forums.phpfreaks.com/topic/167636-another-question-regarding-form-variables/#findComment-884098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.