Autore: Fabio Di Matteo
Ultima revisione: 26/06/2023 - 12:06
sbon.php
function sbonFullName($input) { $allowed = 'abcdefghijklmnopqrstuvwxyz 1234567890'; $ret=true; for($i=0; $i<strlen($input); $i++) { if (strpos($allowed, $input[$i]) === false) { $ret=false; } } return $ret; }
index.php (semplice pagina per le prove)
<?php require('sbon.php') ?> <!DOCTYPE html> <html> <head><title>Sbon</title> <style> div { margin-bottom: 10px; } </style> </head> <body> <h2>Test sbon</h2> <p>A simple page for testing sbon</p> <form method="post" action="index.php"> <div><input type="text" name="string"></div> <div><button name="send" type="submit">Send</button></div> </form> <?php if (isset($_POST["send"])) { if (sbonFullName($_POST['string'])) { echo "<h2>Stringa OK</h2>" ; }else{ echo "<h2>Stringa non valida!</h2>" ; } } ?> </body> </html>