Last Posted October 16, 2013 Share Posted October 16, 2013 I have created a php page that needs to validate if the amount entered is less than 100or must return an error. My function though does not get called when clicking submit even if the amount is less than 100 but link goes straight to the actioned page <html> <head></head> <title></title> <style> .error {color: #FF0000;} </style> <body> <?php function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $amountErr=""; $amount=""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (["amount"]<100) {$amountErr = "Value must be equal or greater than 100";} else {$amount = test_input(["amount"]);} } ?> <p><span class="error">*required field.</span></p> <form action="https://www.moneybookers.com/app/payment.pl" method="post"> <input type="hidden" name="pay_to_email" value="my email account"/> <input type="hidden" name="status_url" value="http://example.com/verify.php"/> <input type="hidden" name="return_url" value="return_page"/> <input type="hidden" name="language" value="EN"/> Amount:<input type="text" name="amount"/> <span class="error">*<?php echo $amountErr;?></span> <input type="hidden" name="currency" value="USD"/> <input type="hidden" name="detail1_description" value="YourApp"/> <input type="hidden" name="detail1_text" value="New Deposit"/><BR> <input type="submit" value="Deposit!"/> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted October 16, 2013 Share Posted October 16, 2013 Try changing ["amount"] to $_POST['amount'] Quote Link to comment Share on other sites More sharing options...
Last Posted October 16, 2013 Author Share Posted October 16, 2013 Thanks for the response cyberRobot but that did not solve it . still proceeds even if the amount is wrong Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 16, 2013 Share Posted October 16, 2013 php code is executed on the server when the page is requested. so, all the php code you have shown has long since ran by the time the form code has been sent to and displayed in the browser. to use php code to validate the data, you would need to have your form submit to the .php page, then build the form that the payment gateway expects with the action set to the payment gateway. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.