Sessions
Is dat met if(isset($_SESSION)); of op een andere manier?
Als de session nog niet gedaan is, moet hij eerst en verificatie doen en als dat gedaan is en goed gekeurd, dan dat hij de pagina verder laadt.
Wat bedoel je met "gedaan is". Geef eens een voorbeeld.
Ozzie PHP op 22/02/2023 13:43:00:
Wat bedoel je met "gedaan is". Geef eens een voorbeeld.
Als je op de page komt, moet je eerst een leeftijd verificatie doen, is deze gedaan dan pas laadt hij de pagina waar je toegang krijgt.
Dus moet de sessie eerst gedaan worden, is deze nog niet gedaan, moet je dus eerst de leeftijd verificatie doen.
Waarschijnlijk bedoel je dat je wil verifiëren of een waarde is geset/ingesteld.
- Ariën - op 22/02/2023 13:49:09:
Thanks, dan moet ik de hele code even aanpassen op dit, maar dat is geen probleem.
Maar dat deed je toch al ... ;-)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
session_start();
error_reporting(0);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if(isset($_SESSION['under18']))
{
echo
"
<head>
<title>Sexy Devil</title>
<link href='inc/div.css' rel='stylesheet' type='text/css'>
</head>
<body>
<div class='text-user'>Insert your birthday to verify</div>
<div class='container'>
<form id='contact' action='index.php' method='POST'>
<fieldset>
<input placeholder='Day' type='number' name='day' value='00' tabindex='1' autofocus>
<input placeholder='Month' type='number' name='month' value='00' tabindex='1' autofocus>
<input placeholder='Year' type='number' name='year' value='0000' tabindex='1' autofocus>
</fielfdset>
<button name='Verify' type='submit' id='contact-submit' data-submit='...Sending'>Verify</button>
</form>
</div>
<div class='text-user'>Under construction, not all working yet</div>
";
}
if(isset($_SESSION['over18']))
{
echo "
<head>
<title>Sexy Devil</title>
<link href='inc/div.css' rel='stylesheet' type='text/css'/>
</head>
<body>
<div class='content'>
<div class='content' id='header'><img src='img/banner.png' width='960px' height='140px'></div>
</div>
<div class='content'>
<div class='content' id='menu'>2</div>
<div class='content' id='profile'>
<div id='photo-name'><p class='text-user'>Delia</p></div>
<img id='photo' src='img/Delia/20221117_233611.JPEG'>
<div id='photo-phone'><p class='text-user'>+31 6 13351720</p></div>
</div>
<div class='content' id='profile'>
<div id='photo-name'><p class='text-user'>Delia</p></div>
<img id='photo' src='img/Delia/20221117_234305.JPEG'>
<div id='photo-phone'><p class='text-user'>+31 6 13351720</p></div></div>
<div class='content' id='profile'>
<div id='photo-name'><p class='text-user'>Delia</p></div>
<img id='photo' src='img/Delia/20221117_234336.JPEG'>
<div id='photo-phone'><p class='text-user'>+31 6 13351720</p></div></div>
</div>
</div>
<div class='content' id='footer'>test</div>
</body>
";
echo "Welcome";
}
if(isset($_POST['submit']))
{
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$birthday = mktime(0,0,0,$month,$day,$year);
$difference = time() - $birthday;
$age = floor($difference / 31556926);
if($age >= 18)
{
$_SESSION['over18'] = 1;
echo "Welcome";
// header('location: index.php');
}else{
$_SESSION['under18'] = 0;
header('location: https://www.disney.com/');
}
}
?>
session_start();
error_reporting(0);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if(isset($_SESSION['under18']))
{
echo
"
<head>
<title>Sexy Devil</title>
<link href='inc/div.css' rel='stylesheet' type='text/css'>
</head>
<body>
<div class='text-user'>Insert your birthday to verify</div>
<div class='container'>
<form id='contact' action='index.php' method='POST'>
<fieldset>
<input placeholder='Day' type='number' name='day' value='00' tabindex='1' autofocus>
<input placeholder='Month' type='number' name='month' value='00' tabindex='1' autofocus>
<input placeholder='Year' type='number' name='year' value='0000' tabindex='1' autofocus>
</fielfdset>
<button name='Verify' type='submit' id='contact-submit' data-submit='...Sending'>Verify</button>
</form>
</div>
<div class='text-user'>Under construction, not all working yet</div>
";
}
if(isset($_SESSION['over18']))
{
echo "
<head>
<title>Sexy Devil</title>
<link href='inc/div.css' rel='stylesheet' type='text/css'/>
</head>
<body>
<div class='content'>
<div class='content' id='header'><img src='img/banner.png' width='960px' height='140px'></div>
</div>
<div class='content'>
<div class='content' id='menu'>2</div>
<div class='content' id='profile'>
<div id='photo-name'><p class='text-user'>Delia</p></div>
<img id='photo' src='img/Delia/20221117_233611.JPEG'>
<div id='photo-phone'><p class='text-user'>+31 6 13351720</p></div>
</div>
<div class='content' id='profile'>
<div id='photo-name'><p class='text-user'>Delia</p></div>
<img id='photo' src='img/Delia/20221117_234305.JPEG'>
<div id='photo-phone'><p class='text-user'>+31 6 13351720</p></div></div>
<div class='content' id='profile'>
<div id='photo-name'><p class='text-user'>Delia</p></div>
<img id='photo' src='img/Delia/20221117_234336.JPEG'>
<div id='photo-phone'><p class='text-user'>+31 6 13351720</p></div></div>
</div>
</div>
<div class='content' id='footer'>test</div>
</body>
";
echo "Welcome";
}
if(isset($_POST['submit']))
{
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$birthday = mktime(0,0,0,$month,$day,$year);
$difference = time() - $birthday;
$age = floor($difference / 31556926);
if($age >= 18)
{
$_SESSION['over18'] = 1;
echo "Welcome";
// header('location: index.php');
}else{
$_SESSION['under18'] = 0;
header('location: https://www.disney.com/');
}
}
?>
Vraag me nu echt af wat ik fout doe
https://www.phphulp.nl/php/forum/topic/verificatie-script/104640/last/
Toevoeging op 22/02/2023 15:25:45:
.