rampspost Posted June 12, 2009 Share Posted June 12, 2009 I have a form, that submits values such as machine readable code from documents, so "P<UTOMAENNIK<<MARI<LIIS<<<<<<<<<<<<<<<<<". After getting these strings with PHP, there is only "P<<<<<<<<<<<<<<<<<<<<<<" inside my variable... How to get it working? Quote Link to comment https://forums.phpfreaks.com/topic/161942-_post-and-_get-values-not-correct/ Share on other sites More sharing options...
rhodesa Posted June 12, 2009 Share Posted June 12, 2009 how are you testing to see what is in your code? are you echoing it? if so, your browser is interpreting it as HTML. try adding this to the top of your script: header('Content-type: text/plain;'); can you post some of your code too? Quote Link to comment https://forums.phpfreaks.com/topic/161942-_post-and-_get-values-not-correct/#findComment-854456 Share on other sites More sharing options...
Chaos Creator Posted June 12, 2009 Share Posted June 12, 2009 When you send your variables to your script, you have to check to make sure they are set. Use something like: if(isset($_POST['whatever'])) { $whatever = $_POST['whatever']; } The same goes for anything passed via GET. Quote Link to comment https://forums.phpfreaks.com/topic/161942-_post-and-_get-values-not-correct/#findComment-854458 Share on other sites More sharing options...
rampspost Posted June 12, 2009 Author Share Posted June 12, 2009 how are you testing to see what is in your code? are you echoing it? if so, your browser is interpreting it as HTML. try adding this to the top of your script: header('Content-type: text/plain;'); can you post some of your code too? <form name="data" action="index.php" method="POST"> <input name="e" maxlength="44" alt="ICAO koodi esimene rida" type="text" class="v2li" value="p<estmaennik<<mari<liis<<<<<<<<<<<<<<<<<<<<<"><br> <input name="t" maxlength="44" alt="ICAO koodi esimene rida" type="text" class="v2li" value="K0000000<0est7302208F111004527302200234<<<16"><br> <input name="k" maxlength="44" alt="ICAO koodi esimene rida" type="text" class="v2li"><br> <div class="nupud"> <input type="reset" value="Tühjenda väljad" class="nupp"> <input type="submit" value="Saada" class="nupp"></div> </form> And in the same index.php file: if (isset($_POST["e"])){ $esimene = (string) $_POST["e"]; $teine = (string) $_POST["t"]; $kolmas = (string) $_POST["k"]; echo "on olemas<br>"; echo $esimene; echo $teine; } else { echo "ei ole olemas"; } and the output is: on olemas p<<<<<<<<<<<<<<<<<<<<<<0est7302208F111004527302200234<<<16 EDIT: There are easy solutions for big problems: everything is there, only the browser won't display it... Quote Link to comment https://forums.phpfreaks.com/topic/161942-_post-and-_get-values-not-correct/#findComment-854473 Share on other sites More sharing options...
rhodesa Posted June 12, 2009 Share Posted June 12, 2009 first, in your form, you should use < instead of a < then, in your PHP use this too: echo htmlspecialchars($esimene); echo htmlspecialchars($teine); Quote Link to comment https://forums.phpfreaks.com/topic/161942-_post-and-_get-values-not-correct/#findComment-854481 Share on other sites More sharing options...
Daniel0 Posted June 12, 2009 Share Posted June 12, 2009 first, in your form, you should use < instead of a < Actually, that doesn't matter with an attribute value as the < doesn't carry any special meaning there, so it doesn't have to be escaped. Quote Link to comment https://forums.phpfreaks.com/topic/161942-_post-and-_get-values-not-correct/#findComment-854503 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.