I have been trying to fix my code and it does not work at all. I have a local server and it does work (use Mamp on my macbook) I edited a small table called "forms" in my "hexameter" database.
Here's my code:
connection.php
<?php
$servername = "";
$username = "";
$password = "";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
Connection does work!
input:
<!DOCTYPE html>
<html>
<body>
<form action="http://localhost:8888/index.php" method="GET">
Hexameter: <input type="text" name="Hexameter"><br>
<input type="submit" name"Eingabe">
</form>
</body>
</html>
index.php:
<!DOCTYPE html PUBLIC>
<html >
<head>
<title>Search results</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<?php
$query = $_GET['Hexameter'];
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$raw_results = mysql_query("SELECT * FROM forms
WHERE `text` LIKE '%".$query."%')" or die(mysql_error());
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo "<p><h3>".$results['title']."</h3>".$results['text']."
</p>";
}
} else{
echo "No results";
}
}
?>
</body>
</html>
I get always to index.php but there is nothing displayed.