m4ttphpnewb Posted February 13, 2008 Share Posted February 13, 2008 Can anyone help me with a code to remove % and ? characters from a text box when a card is swiped through the reader. For example "%ABC?" needs to be changed to "ABC" Thanks! Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/ Share on other sites More sharing options...
Isityou Posted February 13, 2008 Share Posted February 13, 2008 str_replace('%', '') str_replace('?', '') Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-466211 Share on other sites More sharing options...
PHP Monkeh Posted February 13, 2008 Share Posted February 13, 2008 If you're wanting them to be removed from the text box rather than PHP replacing them, you're going to have to look at Javascript. I believe most card readers try to press enter or submit once the card has been scanned, so you could look at some Javascript events for that Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-466256 Share on other sites More sharing options...
m4ttphpnewb Posted February 13, 2008 Author Share Posted February 13, 2008 Ok thank you I will look around. Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-466262 Share on other sites More sharing options...
m4ttphpnewb Posted February 14, 2008 Author Share Posted February 14, 2008 ok I have tried a few things with the str_replace() function and can't seem to get it to work with my text box. this is my last thing to fix on my page and it is driving me nuts.(I had to change script to scrip t to post it in the forum) $fullname = str_replace('%','',$fullname) ; $fullname = str_replace('?','',$fullname); echo " <input type='text' name='left_fullname' id='textbox1' > <scrip t>document.getElementById('textbox1').focus()</scrip t>\n"; if (!$fullname) { echo " <td align=left class=right_main scope=col>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo "<br />\n"; echo "You have not chosen a username. Please try again\n"; include 'footer.php'; exit; } @$fullname = addslashes($fullname); Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467014 Share on other sites More sharing options...
PHP Monkeh Posted February 14, 2008 Share Posted February 14, 2008 What does the card reader output to the text box currently? Is it always characters only or are there numbers aswell? Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467039 Share on other sites More sharing options...
m4ttphpnewb Posted February 14, 2008 Author Share Posted February 14, 2008 it outputs %xyz? to the text box Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467047 Share on other sites More sharing options...
m4ttphpnewb Posted February 14, 2008 Author Share Posted February 14, 2008 I have been testing it with a card encoded as %DEMO1000? I need it to read in the text box as DEMO1000 so the database recognizes it Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467051 Share on other sites More sharing options...
PHP Monkeh Posted February 14, 2008 Share Posted February 14, 2008 Are you bothered about the values within the text box? Because once you submit the form we can let PHP take care of the odd symbols, or would you prefer to use Javascript to get rid of the % and ? as soon as it's swiped. Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467057 Share on other sites More sharing options...
m4ttphpnewb Posted February 14, 2008 Author Share Posted February 14, 2008 i am not bothered by the values in the box, i just need them gone to submit Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467068 Share on other sites More sharing options...
PHP Monkeh Posted February 14, 2008 Share Posted February 14, 2008 Ok then, go to the part of your page where you process the submission. Then you can remove the % and ? by doing this: $fullname=$_POST['left_fullname']; $fullname= str_replace('%','',$fullname) ; $fullname = str_replace('?','',$fullname); That'll remove all % and ? within the textbox after it's submitted, and then you can insert/update your database Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467076 Share on other sites More sharing options...
m4ttphpnewb Posted February 14, 2008 Author Share Posted February 14, 2008 no go, maybe because of this at the beginning of my page? if ($request == 'POST'){ @$fullname = stripslashes($_POST['left_fullname'])}; Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467085 Share on other sites More sharing options...
m4ttphpnewb Posted February 14, 2008 Author Share Posted February 14, 2008 got it! (with your help !!) if ($request == 'POST'){ @$fullname = stripslashes($_POST['left_fullname']); @$fullname= str_replace('%','',$fullname) ; @$fullname = str_replace('?','',$fullname);} Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467088 Share on other sites More sharing options...
m4ttphpnewb Posted February 14, 2008 Author Share Posted February 14, 2008 any idea on how to make it not auto submit when swiped? for now i think I will just move it beneath the buttons and change the buttons so they don't submit then have the whole thing submit with the card swipe. Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467089 Share on other sites More sharing options...
PHP Monkeh Posted February 14, 2008 Share Posted February 14, 2008 It's just what card readers usually do I'm afraid. They automate Enter I think once they've finished swiping, which is what will be submitting the form (probably the first submit button too). There may be a setting that you can change on the card reader though - so that it doesn't auto submit. Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467094 Share on other sites More sharing options...
m4ttphpnewb Posted February 14, 2008 Author Share Posted February 14, 2008 hahah I will beat the card reader! (against the wall till it stops auto entering) nope I will work on a work around and post back when I have out smarted the little piece of hardware, thanks for helping me out so much Im beginning to feel my way around the code much better Link to comment https://forums.phpfreaks.com/topic/90968-swipe-card-code/#findComment-467097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.