header() werkt plotseling niet meer
ik ben ten einde raad.
alles werkte prima de header redirect deed zijn werk. maar plosteling niet meer. ik heb de code opnieuw geschreven en het werkte terug. ik lette er zeer goed op dat er niks kon zijn dat de header zou doen falen. maar het noodlot is weer toegeslagen. ik heb uren liggen zoeken en ik krijg het niet in orde.
ik zou graag een oplossing hebben over wat en hoe dat komt.
de function
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<?php
function register_user() {
$password = mysql_real_escape_string($_POST['password']);
$password = md5($password);
$sql = mysql_query("SELECT id from users WHERE username = '$username'");
$no_rows = mysql_num_rows($sql);
if ($no_rows == 0) {
$result = mysql_query("INSERT INTO users(password, name, email,username, type) values ('$password','".sqlsafe($_POST['name'])."','".sqlsafe($_POST['email'])."','".sqlsafe($_POST['username'])."', '".sqlsafe($_POST['checked'])."')") or die(mysql_error());
header('location:register_wizard.php?username='.sqlsafe($_POST['username']).'');
exit();
}
}
?>
function register_user() {
$password = mysql_real_escape_string($_POST['password']);
$password = md5($password);
$sql = mysql_query("SELECT id from users WHERE username = '$username'");
$no_rows = mysql_num_rows($sql);
if ($no_rows == 0) {
$result = mysql_query("INSERT INTO users(password, name, email,username, type) values ('$password','".sqlsafe($_POST['name'])."','".sqlsafe($_POST['email'])."','".sqlsafe($_POST['username'])."', '".sqlsafe($_POST['checked'])."')") or die(mysql_error());
header('location:register_wizard.php?username='.sqlsafe($_POST['username']).'');
exit();
}
}
?>
de werkelijke pagina
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
94
95
96
97
98
99
100
101
102
103
104
105
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
94
95
96
97
98
99
100
101
102
103
104
105
<?php
include "config.php";
include "lib_functions.php";
if(($_SERVER['REQUEST_METHOD'] == "POST") && ($_POST['register'])) { register_user();
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="jquery.validVal.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#contact").validVal({
// configuration goes here
});
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/maincss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="wrap">
<div class="loginbar">
<div class="header_logbar">
<div class="logoholder"><img src="images/logotransmini.png" width="60" height="45" /></div>
<div class="textinlogingbar"><a href=".">Ik heb al een FFT profiel! <span style="font-weight: bold; color: #999; font-size: 12px;">inloggen</span></a></div>
</div>
</div>
<div class="loginsignupbutholder"></div>
<div class="wrapmid">
<div class="header">
<div class="register_body">
<div class="alinia1">
<div class="register_title"><h1>Registreer je vandaag en start the Fight For Talent</h1></div>
</div>
<div class="alinia1"><form id="contact" name="contact" action="" method="post">
<table width="313" border="0" align="center" cellspacing="2">
<tr>
<td width="300">Volledige naam</td>
</tr>
<tr>
<td height="15"><label for="name"></label>
<input name="name" type="text" class="required textfieldsmain focus" id="name" value="<?php echo $_POST['mainname'] ;?>" /></td>
</tr>
<tr>
<td>E-mailadres</td>
</tr>
<tr>
<td><input name="email" type="text" class="required email focus textfieldsmain" id="email" value="<?php echo $_POST['mainemail'] ;?>" /></td>
</tr>
<tr>
<td>Wachtwoord</td>
</tr>
<tr>
<td><input name="password" type="text" class="required focus textfieldsmain" id="required" value="<?php echo $_POST['mainpassword'] ;?>" /></td>
</tr>
<tr>
<td>Gebruikersnaam</td>
</tr>
<tr>
<td><input name="username" type="text" class="required focus textfieldsmain focus" id="username" value="" /></td>
</tr>
<tr>
<td><input name="checked" type="checkbox" id="checked" value="1" />
<label for="checked"></label>
Ik maak een profiel aan voor een bedrijf</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="font-weight: normal">Door op onderstaande knop te klikken aanvaard je de algemene voorwaarden. De algemene voorwaarden kan je hier lezen.</td>
</tr>
<tr>
<td><input name="register" type="submit" class="register" id="register" value="Maak mijn profiel aan" /></td>
</tr>
</table>
</form></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
?>
include "config.php";
include "lib_functions.php";
if(($_SERVER['REQUEST_METHOD'] == "POST") && ($_POST['register'])) { register_user();
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="jquery.validVal.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#contact").validVal({
// configuration goes here
});
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/maincss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="wrap">
<div class="loginbar">
<div class="header_logbar">
<div class="logoholder"><img src="images/logotransmini.png" width="60" height="45" /></div>
<div class="textinlogingbar"><a href=".">Ik heb al een FFT profiel! <span style="font-weight: bold; color: #999; font-size: 12px;">inloggen</span></a></div>
</div>
</div>
<div class="loginsignupbutholder"></div>
<div class="wrapmid">
<div class="header">
<div class="register_body">
<div class="alinia1">
<div class="register_title"><h1>Registreer je vandaag en start the Fight For Talent</h1></div>
</div>
<div class="alinia1"><form id="contact" name="contact" action="" method="post">
<table width="313" border="0" align="center" cellspacing="2">
<tr>
<td width="300">Volledige naam</td>
</tr>
<tr>
<td height="15"><label for="name"></label>
<input name="name" type="text" class="required textfieldsmain focus" id="name" value="<?php echo $_POST['mainname'] ;?>" /></td>
</tr>
<tr>
<td>E-mailadres</td>
</tr>
<tr>
<td><input name="email" type="text" class="required email focus textfieldsmain" id="email" value="<?php echo $_POST['mainemail'] ;?>" /></td>
</tr>
<tr>
<td>Wachtwoord</td>
</tr>
<tr>
<td><input name="password" type="text" class="required focus textfieldsmain" id="required" value="<?php echo $_POST['mainpassword'] ;?>" /></td>
</tr>
<tr>
<td>Gebruikersnaam</td>
</tr>
<tr>
<td><input name="username" type="text" class="required focus textfieldsmain focus" id="username" value="" /></td>
</tr>
<tr>
<td><input name="checked" type="checkbox" id="checked" value="1" />
<label for="checked"></label>
Ik maak een profiel aan voor een bedrijf</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="font-weight: normal">Door op onderstaande knop te klikken aanvaard je de algemene voorwaarden. De algemene voorwaarden kan je hier lezen.</td>
</tr>
<tr>
<td><input name="register" type="submit" class="register" id="register" value="Maak mijn profiel aan" /></td>
</tr>
</table>
</form></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
?>
Je bent vergeten op regel 5 php af te sluiten.
nee nee dat komt door hier te pasten in werkelijkheid is dat niet.
In de function gebruik je diverse $vars die niet bestaan.
30719 krijg ik als melding
echo error_reporting(E_ALL);
en dat moet zijn:
error_reporting(E_ALL);
Beter nog is:
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
Gewijzigd op 11/05/2013 15:53:13 door - SanThe -
Warning: Cannot modify header information - headers already sent by (output started at /data/sites/web/fightfortalentbe/www/lib_function_register.php:20) in /data/sites/web/fightfortalentbe/www/lib_function_register.php on line 22
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
//safety messures
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
function sqlsafe($data) {
$data = mysql_real_escape_string($data);
return $data;
}
// Make MySQL-database connection
@mysql_connect($server, $user, $pass) or die ("Can't connect to MySQL database server");
@mysql_select_db($database) or die("Can't find database.");
function register_user() {
$password = mysql_real_escape_string($_POST['password']);
$password = md5($password);
$sql = mysql_query("SELECT id from users WHERE username = '".sqlsafe($_POST['username'])."'");
$no_rows = mysql_num_rows($sql);
if ($no_rows == 0) {
$registeruser = mysql_query("INSERT INTO users(password, name, email,username, type) values ('$password','".sqlsafe($_POST['name'])."','".sqlsafe($_POST['email'])."','".sqlsafe($_POST['username'])."', '".sqlsafe($_POST['checked'])."')") or die(mysql_error());
if($registeruser) {
header('location:user_profile.php'); }} }
?>
//safety messures
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
function sqlsafe($data) {
$data = mysql_real_escape_string($data);
return $data;
}
// Make MySQL-database connection
@mysql_connect($server, $user, $pass) or die ("Can't connect to MySQL database server");
@mysql_select_db($database) or die("Can't find database.");
function register_user() {
$password = mysql_real_escape_string($_POST['password']);
$password = md5($password);
$sql = mysql_query("SELECT id from users WHERE username = '".sqlsafe($_POST['username'])."'");
$no_rows = mysql_num_rows($sql);
if ($no_rows == 0) {
$registeruser = mysql_query("INSERT INTO users(password, name, email,username, type) values ('$password','".sqlsafe($_POST['name'])."','".sqlsafe($_POST['email'])."','".sqlsafe($_POST['username'])."', '".sqlsafe($_POST['checked'])."')") or die(mysql_error());
if($registeruser) {
header('location:user_profile.php'); }} }
?>
Anthony de meulemeester op 11/05/2013 16:09:44:
Notice: Undefined index: checked in /data/sites/web/fightfortalentbe/www/lib_function_register.php on line 20
En daar heb je het probleem.
best handige functie die error report
thxx .