I have a PHP form that self processes. It passes data with POST. Works flawlessly on desktop browsers but does not work on Chrome for Android, Safari or Chrome for iOS and iOS simulator. For the sake of brevity, I will share the parts of this file that are not working as there is quite a bit of validation that goes on.
Here is the beginning of my HTML form input:
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="voucher-input first-input">
Voucher 1: <input maxlength="20" type="text" name="voucher1" id="voucher1" title="Voucher" class="input" value="<?php echo $voucher1;?>">
Here is the receiving part of my form "action" that captures POST data:
$voucher1 = test_input($_POST["voucher1"]);
When it captures this voucher1, it passes it off for form validation. The first step is to remove white space and illegal characters, then it ensures that the voucher is prefixed with a valid 3 letter prefix (in this case I am using STL). If that passes, then it goes through the trouble of adding it to a PHP array.
$stl = 'STL'; // Defines a string that is needed for the next step
$posstl = strpos($voucher1, $stl); // Checks if 'STL' is at beginning of $voucher1 input. All vouchers must start with an authorized prefix.
if ($posstl === 0) { // If STL is at the beginning of position 0 of string
/** Create Empty Voucher Array **/
$redeemids = array();
echo "Adding voucher to array";
array_push($redeemids, $voucher1);
print_r($redeemids);}
On desktops, it does all of this. On mobile, it doesn't even echo "Adding voucher to array" which tells me it is failing the IF conditional for mobile devices. So to eliminate the variables, either this method of POST does not work for mobile, my form HTML is invalid or the there is a problem with my conditional. Any ideas?