Compare commits

...

2 Commits

Author SHA1 Message Date
David Renner 17c99c1e4c . 2020-06-08 12:41:39 +02:00
David Renner 5bcfce5caa form data to json per php works! 2020-06-08 12:33:06 +02:00
3 changed files with 79 additions and 16 deletions

View File

@ -31,7 +31,7 @@ Das war die alte version. -->
<div class="Eingabe">
<h2>Eingabe</h2>
<form action="/php/catalogue_search.php">
<form action="./php/catalogue_search.php" method="POST">
<input type="text" name="Title" id="input" placeholder="Titel">
<input type="text" name="Author" id="input" placeholder="Autor">
<input type="text" name="Country" id="input" placeholder="Herkunft">
@ -39,10 +39,20 @@ Das war die alte version. -->
<input type="text" name="Language" id="input" placeholder="Sprache">
<input type="number" name="Pages" id="input" placeholder="Seiten">
<input type="date" name="Year" id="input" placeholder="Erscheinungsjahr"> <!-- Nur YYYY-->
<input type="text" name="Category" id="input" placeholder="Kategorie"> <!-- Nur Auswahl (per select?) -->
<input list="categories" name="Category" id="input" placeholder="Kategorie"> <!-- Nur Auswahl (per select?) -->
<datalist id="categories">
<option value="Buch">
<option value="Magazin">
<option value="E-Book">
<option value="e-Magazin">
</datalist>
<input type="url" name="ImageLink" id="input" placeholder="Bild">
<input type="number" name="LendTime" id="input" placeholder="Verteihdauer">
<input type="text" name="LendType" id="input" placeholder="Verleihtyp">
<input list="types" name="LendType" id="input" placeholder="Verleihtyp">
<datalist id="types">
<option value="Physisch">
<option value="Virtuell">
</datalist>
<input type="submit" name="go" id="go">
</form>
</div>

View File

@ -1,14 +1,9 @@
<html>
<body>
<?php
$form = array("Title"=>$_GET["Title"],array("Author"=>$_GET["Author"]);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
echo json_encode($form);
</body>
</html>
?>
$form = array("Title"=>$_POST["Title"],"Author"=>$_POST["Author"]);
$form = json_encode($form);
echo $form
?>
</body>
</html>

58
php/pasta.php Normal file
View File

@ -0,0 +1,58 @@
<?php
if(isset($_POST['link'])) {
$link = $_POST['link'];
//remove protocol, we're assuming its http
if(strstr($link, '://') != false){
$link = substr($link, strpos($link,'://') + strlen('://'));
}
//split the url into host (www.example.com) and requested page (index.php) on the first slash
$host = substr($link, 0, strpos($link, '/'));
$request = substr($link, strpos($link, '/'));
//open a socket connection to the site on port 80 (http protocol port)
$fp = @fsockopen($host, 80, $errno, $errstr);
if($fp == false){
$response = $errno . " " . $errstr;
}
else {
//create the request headers
$headers = array();
$headers[] = 'HEAD ' . $request . ' HTTP/1.1';
$headers[] = 'Host: ' . $host;
$headers[] = 'Content-Length: 0';
$headers[] = 'Connection: close';
$headers[] = 'Content-Type: text/html';
$headers = implode("\r\n", $headers) . "\r\n\r\n";
//send our request
if (!fwrite($fp, $headers)) {
fclose($fp);
$response = "Could not access webpage specified.";
}
else {
//read the response
$rsp = '';
while(!feof($fp)) { $rsp .= fgets($fp,8192); }
fclose($fp);
$hunks = explode("\r\n\r\n",trim($rsp));
$headers = explode("\n", $hunks[count($hunks) - 1]);
$response = trim($headers[0]);
}
}
}
?>
<html>
<head>
<title>Test Link</title>
</head>
<body>
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<label for="link">Link</label>
<input id="link" type="text" name="link" />
</form>
</body>
</html>