Plaatje in beeld brengen met PHP
Ik wil een plaat je beeld brengen met php. (Dit moet uiteindelijk een boek worden, maar das hier relevant)
Nu heb ik de volgende code:
idex.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require_once('./operations.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1 class="text-center my- 3" >Registration Form</h1>
<div class = "container d-flex justify-content-center">
<form action="display.php" method= "POST" class="w-50" enctype="multipart/form-data">
<?php
echo inputFields("Username","username","","text");
echo inputFields("Mobile","mobile","","text");
echo inputFields("","file","","file");
?>
<button class="btn btn-dark" type="submit" name = "submit">Submit</button>
</form>
</div>
</body>
</html>
require_once('./operations.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1 class="text-center my- 3" >Registration Form</h1>
<div class = "container d-flex justify-content-center">
<form action="display.php" method= "POST" class="w-50" enctype="multipart/form-data">
<?php
echo inputFields("Username","username","","text");
echo inputFields("Mobile","mobile","","text");
echo inputFields("","file","","file");
?>
<button class="btn btn-dark" type="submit" name = "submit">Submit</button>
</form>
</div>
</body>
</html>
connect.php
Code (php)
connect.php
Code (php)
Nu krijg ik de volgende foutmelding:
Connection Succesful
Notice: Undefined index: file in C:\USB WebServer\root\Youtube9\display.php on line 8
ed
2
Displaying Data
Wat is hier het probleem?
Blijkbaar roep je een waarde aan die niet bestaat.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
include ('./connect.php');
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$mobile = $_POST['mobile'];
$image = $_FILES['file'];
echo $username;
echo "<br>";
echo $mobile;
echo "<br>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display Data</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1>Displaying Data</h1>
</body>
</html>
include ('./connect.php');
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$mobile = $_POST['mobile'];
$image = $_FILES['file'];
echo $username;
echo "<br>";
echo $mobile;
echo "<br>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display Data</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1>Displaying Data</h1>
</body>
</html>
Hoi,
Het bestand wat ontbrak....
Toevoeging op 09/05/2022 18:02:14:
De laatste is dus display.php
Gewijzigd op 09/05/2022 19:20:34 door - Ariën -
Hoe ziet je upload-formulier eruit?
das idex.php (bij mij index.php). Dat zit er dus bij
Gewijzigd op 09/05/2022 18:34:45 door - Ariën -
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require_once('./operations.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1 class="text-center my- 3" >Registration Form</h1>
<div class = "container d-flex justify-content-center">
<form action="display.php" method= "POST" class="w-50" enctype="multipart/form-data">
<?php
echo inputFields("Username","username","","text");
echo inputFields("Mobile","mobile","","text");
echo inputFields("","file","","file");
?>
<button class="btn btn-dark" type="submit" name = "submit">Submit</button>
</form>
</div>
</body>
</html>
require_once('./operations.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1 class="text-center my- 3" >Registration Form</h1>
<div class = "container d-flex justify-content-center">
<form action="display.php" method= "POST" class="w-50" enctype="multipart/form-data">
<?php
echo inputFields("Username","username","","text");
echo inputFields("Mobile","mobile","","text");
echo inputFields("","file","","file");
?>
<button class="btn btn-dark" type="submit" name = "submit">Submit</button>
</form>
</div>
</body>
</html>
Toevoeging op 09/05/2022 18:57:52:
Das mijn index.php. Daar wordt ook alles geupload
Gewijzigd op 09/05/2022 19:20:22 door - Ariën -
Daarom vraag ik ook de HTML-code. Dus tover die eens uit je browser.
die staat er toch boven? ik snap hem anders niet
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
function inputFields($placeholder,$name,$value,$type)
{
$ele="
<div class=\"form-group my-4\">
<input tyoe ='$type' name='$name' placeholder='$placeholder' class=\"form-control\" value='$value' autocomplete =\"off\">
</div>
";
echo $ele;
}
?>
function inputFields($placeholder,$name,$value,$type)
{
$ele="
<div class=\"form-group my-4\">
<input tyoe ='$type' name='$name' placeholder='$placeholder' class=\"form-control\" value='$value' autocomplete =\"off\">
</div>
";
echo $ele;
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1 class="text-center my- 3" >Registration Form</h1>
<div class = "container d-flex justify-content-center">
<form action="display.php" method= "POST" class="w-50">
<div class="form-group my-4">
<input type ='text' name='username' placeholder='Username' class="form-control" value='' autocomplete ="off">
</div>
<div class="form-group my-4">
<input type ='text' name='mobile' placeholder='Mobile' class="form-control" value='' autocomplete ="off">
</div>
<div class="form-group my-4">
<input type ='file' name='file' placeholder='' class="form-control" value='' autocomplete ="off">
</div>
<button class="btn btn-dark" type="submit" name = "submit">Submit</button>
</form>
</div>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1 class="text-center my- 3" >Registration Form</h1>
<div class = "container d-flex justify-content-center">
<form action="display.php" method= "POST" class="w-50">
<div class="form-group my-4">
<input type ='text' name='username' placeholder='Username' class="form-control" value='' autocomplete ="off">
</div>
<div class="form-group my-4">
<input type ='text' name='mobile' placeholder='Mobile' class="form-control" value='' autocomplete ="off">
</div>
<div class="form-group my-4">
<input type ='file' name='file' placeholder='' class="form-control" value='' autocomplete ="off">
</div>
<button class="btn btn-dark" type="submit" name = "submit">Submit</button>
</form>
</div>
</body>
</html>
Gewijzigd op 09/05/2022 19:20:08 door - Ariën -
Ik denk eerder dat dat er niks ingevuld is als upload.
er wordt wel degelijk iets ingevuld!
Connection Succesful
Notice: Undefined index: file in C:\USB WebServer\root\Youtube9\display.php on line 8
ed
1
Displaying Data
Je aanpassing ha ik al gedaan, maar levert helaas niet het gewenste resultaat op.
Het werkt nu wel!
Gewijzigd op 09/05/2022 22:48:04 door - Ariën -
Index.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require_once('./operations.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1 class="text-center my- 3" >Registration Form</h1>
<div class = "container d-flex justify-content-center">
<form action="" class="w-50">
<?php
return $ele;
function inputFields("Username","username","","text");
function inputFields("Mobile","mobile","","text");
function inputFields("","file","","file");
?>
</form>
</div>
</body>
</html>
require_once('./operations.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1 class="text-center my- 3" >Registration Form</h1>
<div class = "container d-flex justify-content-center">
<form action="" class="w-50">
<?php
return $ele;
function inputFields("Username","username","","text");
function inputFields("Mobile","mobile","","text");
function inputFields("","file","","file");
?>
</form>
</div>
</body>
</html>
Operations.php
Code (php)
display.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display Data</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1>Displying Data</h1>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display Data</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<body>
<h1>Displying Data</h1>
</body>
</html>
connect.php
Code (php)
Gewijzigd op 10/05/2022 16:37:24 door - Ariën -
Niemand gaat regel voor regel die 60 regels code regel voor regel vergelijken