Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <meta charset="utf-8">
- <?php
- session_start();
- $dbserver = "localhost";
- $dbuser = "root";
- $dbpwd = "";
- $db = "words";
- $link = mysqli_connect($dbserver, $dbuser, $dbpwd, $db);
- if(mysqli_connect_errno() > 0){
- echo mysqli_connect_error();
- die;
- }
- mysqli_query($link,"SET NAMES UTF8");
- $sql = "SELECT word,url FROM words";
- $result = mysqli_query($link,$sql);
- while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
- {
- $a[] = $row;
- }
- $arr = explode( " ", $_POST['textarea'] );
- foreach ($arr as $word){
- foreach ($a as $key){
- if($word == $key['word']){
- $word = "<a href=" . $key['url'] . ">" . $key['word'] . "</a>";
- }
- }
- $words[] = $word;
- }
- $_SESSION['words'] = $words;
- header("Location: /");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement