Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // jedna mała funkcja
- function cleanText($wert) {
- $wert = strip_tags($wert);
- $wert = htmlentities($wert, ENT_QUOTES, "UTF-8");
- $wert = trim($wert);
- $wert = stripslashes($wert);
- $wert = nl2br($wert);
- //$wert = mysql_real_escape_string($wert); // Jeżeli używasz PDO to zakomentuj to, jeżeli mysql_query to odkoduj
- return $wert;
- }
- // przykład użycia
- $text = cleanText($_POST['text']);
- $time = cleanText( time() );
- $id = cleanText($_GET['id']);
- //dodawanie do mysql
- $db->query("INSERT INTO `user` (`id_user`, `punkty`) VALUES ('$text', '$time');");
- //wyświetlanie z mysql
- $sql = $db->query("SELECT * FROM user WHERE id='$id' ");
- foreach($sql as $row) {
- echo $row['text'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement