Include function plaatst op verkeerde plek
Ik ben begonnen aan een nieuw project om weer lekker diep php in te duiken en er weer goed van te leren. Maar nu liep ik tegen het volgende probleem aan:
Stel je hebt de layout zo geschreven (denk je):
Header.php
Index.php
Footer.php
Dus bovenaan de header, daaronder de content, en daaronder de footer. Dit heb ik geloof ik ook gedaan. Maar mijn code doet dit:
header.php
footer.php
index.php
Dus hij zet de footer boven de index neer, en dat is niet de bedoeling.
Ik heb hier de code van de 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
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
92
93
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
92
93
<?php include('header.php'); ?>
<div class="center">
<table>
<tr>
<td>
<form action="register.php" method="post"></td>
<td>All fields that are marked with a (*) are required!</td>
</tr>
<tr>
<td>First Name</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="firstname" value="<?php echo"$firstname"; ?>"/></td>
</tr>
<tr>
<td>Middle Name</td>
<td class="bright_red" width="5px;"></td>
<td><input type="text" name="middlename" value="<?php echo"$middlename"; ?>" /></td>
</tr>
<tr>
<td>Last Name</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="lastname" value="<?php echo"$lastname"; ?>" /></td>
</tr>
<tr>
<td>Country</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="country" value="<?php echo"$country"; ?>" /></td>
</tr>
<tr>
<td>State</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="state" value="<?php echo"$state"; ?>" /></td>
</tr>
<tr>
<td>City</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="city" value="<?php echo"$city"; ?>" /></td>
</tr>
<tr>
<td>Postal/Zip Code</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="zip" value="<?php echo"$zip"; ?>" /></td>
</tr>
<tr>
<td>Phone</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="phone" value="<?php echo"$phone"; ?>" /></td>
</tr>
<tr>
<td>Website</td>
<td class="bright_red" width="5px;"></td>
<td><input type="text" name="website" value="<?php echo"$website"; ?>" /></td>
</tr>
<tr>
<td>Youtube</td>
<td class="bright_red" width="5px;"></td>
<td><input type="text" name="youtube" value="<?php echo"$youtube"; ?>" /></td>
</tr>
<tr>
<td>Email Address</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="email1" value="<?php echo"$email1"; ?>" /></td>
</tr>
<tr>
<td>Confirm Email</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="email2" /></td>
</tr>
<tr>
<td>Create password</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="password" name="password1" value="<?php echo"$password1"; ?>" /></td>
</tr>
<tr>
<td>Confirm password</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="password" name="password2" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" name="submit" value="Sign Up" />
</td>
</tr>
</div>
<?php include('footer.php'); ?>
<div class="center">
<table>
<tr>
<td>
<form action="register.php" method="post"></td>
<td>All fields that are marked with a (*) are required!</td>
</tr>
<tr>
<td>First Name</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="firstname" value="<?php echo"$firstname"; ?>"/></td>
</tr>
<tr>
<td>Middle Name</td>
<td class="bright_red" width="5px;"></td>
<td><input type="text" name="middlename" value="<?php echo"$middlename"; ?>" /></td>
</tr>
<tr>
<td>Last Name</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="lastname" value="<?php echo"$lastname"; ?>" /></td>
</tr>
<tr>
<td>Country</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="country" value="<?php echo"$country"; ?>" /></td>
</tr>
<tr>
<td>State</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="state" value="<?php echo"$state"; ?>" /></td>
</tr>
<tr>
<td>City</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="city" value="<?php echo"$city"; ?>" /></td>
</tr>
<tr>
<td>Postal/Zip Code</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="zip" value="<?php echo"$zip"; ?>" /></td>
</tr>
<tr>
<td>Phone</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="phone" value="<?php echo"$phone"; ?>" /></td>
</tr>
<tr>
<td>Website</td>
<td class="bright_red" width="5px;"></td>
<td><input type="text" name="website" value="<?php echo"$website"; ?>" /></td>
</tr>
<tr>
<td>Youtube</td>
<td class="bright_red" width="5px;"></td>
<td><input type="text" name="youtube" value="<?php echo"$youtube"; ?>" /></td>
</tr>
<tr>
<td>Email Address</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="email1" value="<?php echo"$email1"; ?>" /></td>
</tr>
<tr>
<td>Confirm Email</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="text" name="email2" /></td>
</tr>
<tr>
<td>Create password</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="password" name="password1" value="<?php echo"$password1"; ?>" /></td>
</tr>
<tr>
<td>Confirm password</td>
<td class="bright_red" width="5px;">*</td>
<td><input type="password" name="password2" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" name="submit" value="Sign Up" />
</td>
</tr>
</div>
<?php include('footer.php'); ?>
En ik heb natuurlijk de css:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
html {background:#E1EBF4 url(images/topbar.png) repeat-x; font-family:"Trebuchet MS",Helvetica,Jamrul,sans-serif; font-size:14px; color:#313F5E;}
body {margin:0;}
.center {margin:0 auto; width:960px;}
#top {height:35px; color:#58688A; padding:10px; text-transform:uppercase; font-weight:bold;}
#top span {color:#F7AC08;}
#final {background:#262C44; min-height:70px; color:#58688A;}
#final div {margin:0 auto; width:920px; padding:20px;}
/*Lettertypes/color*/
.bright_red{color:#F00;}
body {margin:0;}
.center {margin:0 auto; width:960px;}
#top {height:35px; color:#58688A; padding:10px; text-transform:uppercase; font-weight:bold;}
#top span {color:#F7AC08;}
#final {background:#262C44; min-height:70px; color:#58688A;}
#final div {margin:0 auto; width:920px; padding:20px;}
/*Lettertypes/color*/
.bright_red{color:#F00;}
En om het compleet te maken,
De header:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='nl' lang='nl'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Even weggehaald</title>
<link rel='stylesheet' href='style.css' type='text/css' media='screen' />
</head>
<body>
<div class='center'>
<div id='top'>
<a href='index.html' title=''>Home</a> | Bel Webbart: <span>06-1234 5678</span>
</div>
</div>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='nl' lang='nl'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Even weggehaald</title>
<link rel='stylesheet' href='style.css' type='text/css' media='screen' />
</head>
<body>
<div class='center'>
<div id='top'>
<a href='index.html' title=''>Home</a> | Bel Webbart: <span>06-1234 5678</span>
</div>
</div>
En tot slot de footer:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<div id='final'>
<div>© 2011-2012 Web-bart</div>
</div>
</div>
</body>
</html>
<div>© 2011-2012 Web-bart</div>
</div>
</div>
</body>
</html>
Dus nog 1x het probleem:
De header staat netjes bovenaan de pagina. Maar de footer staat onder de header, en de content staat onder de footer...
Wie weet hoe ik dit weer een beetje logisch kan maken?
Groeten,
B. Roelofs
P.s dit script is nog niet af, maar ik weet niet hoe ik dit probleem kan oplossen. Dit script voert momenteel nog niets uit.
Gewijzigd op 16/12/2011 14:45:35 door Bart Roelofs
Maar probleem niet opgelost. In de browser google chrome zet hij hem bovenaan. Maar in mozilla krijg ik de footer wel gewoon onderaan zie ik net.
B. Roelofs
Gewijzigd op 16/12/2011 16:48:39 door Bart Roelofs
EDIT:
Kan het niet helemaal goed zien op deze manier.
Maar is de </div> op lijn 7 in footer.php wel nodig.
Lijkt mij een overbodige tag afsluiting.
Gewijzigd op 16/12/2011 16:52:30 door Frank WD
B. Roelofs
Je kan controleren of dat het probleem is door in de browser de source te bekijken. De source is namelijk precies zoals je php het echoed, maar wat je op je scherm ziet is hoe de browser het interpreteert. Bij het missen van afsluitende tags gaan verschillende browsers verschillende dingen doen. De source is echter overal gelijk, dat passen ze niet aan.
Is altijd handig te weten voor eventueel iemand die alter met zelfde probleem komt.
Maar mooi dat het werkt
B. Roelofs