Register button werkt niet
Ik wil een inlog pagina maken op mijn site en heb daarvoor een design gedownload die d.m.v fading wisselt tussen formulieren. Zo kan je wisselen naar login, registreren en wachtwoord vergeten.
Wanneer ik op de index.php een stuk php code bijvoeg en dat daarna test, kan ik niet op de link registreren klikken, ook wanneer ik een pagina register.php aanmaak en de browser daar naar toe stuur. Oorspronkelijk zitten de bestanden register.php, forgot_password.php en index.php erbij. Vanuit de index.php pagina wordt de browser naar bv. register.php gestuurd als iemand op de link daarvoor drukt.
Ik heb geprobeerd de php code toe te voegen in de index.php pagina en op de register.php pagina. Op de laatst genoemde pagina heb ik het formulier nog de class 'active' gegeven zoals staat beschreven onder aan het bronbestand.
Hier is de broncode van 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
include ('connection/connection.php');
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']))
{
// SQL-injectie tegengaan
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$voornaam = mysql_real_escape_string($_POST['voornaam']);
$achternaam = mysql_real_escape_string($_POST['achternaam']);
$website = mysql_real_escape_string($_POST['website']);
$updates = mysql_real_escape_string($_POST['updates']);
// MD5 hash toevoegen aan wachtwoord
$password = md5($_POST['password']);
// Kijken of er al een gebruiker bestaat met de opgegeven username
$spl = mysql_query("SELECT username FROM cms WHERE username = '".$username."'");
if(mysql_num_rows($sql)>0)
{
die ("Gebruikersnaam al in gebruik!");
}
mysql_query("INSERT INTO cms (username, password, email, voornaam, achternaam, website) VALUES ( '$username', '$password', '$email', '$voornaam', '$achternaam', '$website')")
or die (mysql_error());
echo '<p style="color:green">Uw account is succesvol aangemaakt!</p>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>titel</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="css/login.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="../../js/cufon-yui.js" type="text/javascript"></script>
<script src="../../js/ChunkFive_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
Cufon.replace('h1',{ textShadow: '1px 1px #fff'});
Cufon.replace('h2',{ textShadow: '1px 1px #fff'});
Cufon.replace('h3',{ textShadow: '1px 1px #000'});
Cufon.replace('.back');
</script>
</head>
<body>
<img src="img/logo.png" class="logo"/>
<div class="wrapper">
<div class="content">
<div id="form_wrapper" class="form_wrapper">
<form class="register active" name="register" action="<?php $_SERVER['PHP_SELF'] ?>">
<h3>Register</h3>
<div class="column">
<div>
<label>First Name:</label>
<input name="voornaam" type="text" />
<span class="error">This is an error</span>
</div>
<div>
<label>Last Name:</label>
<input name="achternaam" type="text" />
<span class="error">This is an error</span>
</div>
<div>
<label>Website:</label>
<input name="website" type="text" value="http://"/>
<span class="error">This is an error</span>
</div>
</div>
<div class="column">
<div>
<label>Username:</label>
<input name="username" type="text"/>
<span class="error">This is an error</span>
</div>
<div>
<label>Email:</label>
<input name="email" type="text" />
<span class="error">This is an error</span>
</div>
<div>
<label>Password:</label>
<input name="password" type="password" />
<span class="error">This is an error</span>
</div>
</div>
<div class="bottom">
<div class="remember">
<input name="updates" value="1" type="checkbox" />
<span>Send me updates</span>
</div>
<input type="submit" value="Register" />
<a href="register.php" rel="login" class="linkform">You have an account already? Log in here</a>
<div class="clear"></div>
</div>
</form>
<form class="login active">
<h3>Login</h3>
<div>
<label>Username:</label>
<input type="text" />
<span class="error">This is an error</span>
</div>
<div>
<label>Password: <a href="forgot_password.php" rel="forgot_password" class="forgot linkform">Forgot your password?</a></label>
<input type="password" />
<span class="error">This is an error</span>
</div>
<div class="bottom">
<div class="remember"><input type="checkbox" /><span>Keep me logged in</span></div>
<input type="submit" value="Login"></input>
<a href="index.php" rel="register" class="linkform">You don't have an account yet? Register here</a>
<div class="clear"></div>
</div>
</form>
<form class="forgot_password">
<h3>Forgot Password</h3>
<div>
<label>Username or Email:</label>
<input type="text" />
<span class="error">This is an error</span>
</div>
<div class="bottom">
<input type="submit" value="Send reminder"></input>
<a href="index.php" rel="login" class="linkform">Suddenly remebered? Log in here</a>
<a href="register.php" rel="register" class="linkform">You don't have an account? Register here</a>
<div class="clear"></div>
</div>
</form>
</div>
<div class="clear"></div>
</div>
</div>
<!-- The JavaScript -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
//the form wrapper (includes all forms)
var $form_wrapper = $('#form_wrapper'),
//the current form is the one with class active
$currentForm = $form_wrapper.children('form.active'),
//the change form links
$linkform = $form_wrapper.find('.linkform');
//get width and height of each form and store them for later
$form_wrapper.children('form').each(function(i){
var $theForm = $(this);
//solve the inline display none problem when using fadeIn fadeOut
if(!$theForm.hasClass('active'))
$theForm.hide();
$theForm.data({
width : $theForm.width(),
height : $theForm.height()
});
});
//set width and height of wrapper (same of current form)
setWrapperWidth();
/*
clicking a link (change form event) in the form
makes the current form hide.
The wrapper animates its width and height to the
width and height of the new current form.
After the animation, the new form is shown
*/
$linkform.bind('click',function(e){
var $link = $(this);
var target = $link.attr('rel');
$currentForm.fadeOut(400,function(){
//remove class active from current form
$currentForm.removeClass('active');
//new current form
$currentForm= $form_wrapper.children('form.'+target);
//animate the wrapper
$form_wrapper.stop()
.animate({
width : $currentForm.data('width') + 'px',
height : $currentForm.data('height') + 'px'
},500,function(){
//new form gets class active
$currentForm.addClass('active');
//show the new form
$currentForm.fadeIn(400);
});
});
e.preventDefault();
});
function setWrapperWidth(){
$form_wrapper.css({
width : $currentForm.data('width') + 'px',
height : $currentForm.data('height') + 'px'
});
}
/*
for the demo we disabled the submit buttons
if you submit the form, you need to check the
which form was submited, and give the class active
to the form you want to show
*/
$form_wrapper.find('input[type="submit"]')
.click(function(e){
e.preventDefault();
});
});
</script>
</body>
</html>
include ('connection/connection.php');
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']))
{
// SQL-injectie tegengaan
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$voornaam = mysql_real_escape_string($_POST['voornaam']);
$achternaam = mysql_real_escape_string($_POST['achternaam']);
$website = mysql_real_escape_string($_POST['website']);
$updates = mysql_real_escape_string($_POST['updates']);
// MD5 hash toevoegen aan wachtwoord
$password = md5($_POST['password']);
// Kijken of er al een gebruiker bestaat met de opgegeven username
$spl = mysql_query("SELECT username FROM cms WHERE username = '".$username."'");
if(mysql_num_rows($sql)>0)
{
die ("Gebruikersnaam al in gebruik!");
}
mysql_query("INSERT INTO cms (username, password, email, voornaam, achternaam, website) VALUES ( '$username', '$password', '$email', '$voornaam', '$achternaam', '$website')")
or die (mysql_error());
echo '<p style="color:green">Uw account is succesvol aangemaakt!</p>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>titel</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="css/login.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="../../js/cufon-yui.js" type="text/javascript"></script>
<script src="../../js/ChunkFive_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
Cufon.replace('h1',{ textShadow: '1px 1px #fff'});
Cufon.replace('h2',{ textShadow: '1px 1px #fff'});
Cufon.replace('h3',{ textShadow: '1px 1px #000'});
Cufon.replace('.back');
</script>
</head>
<body>
<img src="img/logo.png" class="logo"/>
<div class="wrapper">
<div class="content">
<div id="form_wrapper" class="form_wrapper">
<form class="register active" name="register" action="<?php $_SERVER['PHP_SELF'] ?>">
<h3>Register</h3>
<div class="column">
<div>
<label>First Name:</label>
<input name="voornaam" type="text" />
<span class="error">This is an error</span>
</div>
<div>
<label>Last Name:</label>
<input name="achternaam" type="text" />
<span class="error">This is an error</span>
</div>
<div>
<label>Website:</label>
<input name="website" type="text" value="http://"/>
<span class="error">This is an error</span>
</div>
</div>
<div class="column">
<div>
<label>Username:</label>
<input name="username" type="text"/>
<span class="error">This is an error</span>
</div>
<div>
<label>Email:</label>
<input name="email" type="text" />
<span class="error">This is an error</span>
</div>
<div>
<label>Password:</label>
<input name="password" type="password" />
<span class="error">This is an error</span>
</div>
</div>
<div class="bottom">
<div class="remember">
<input name="updates" value="1" type="checkbox" />
<span>Send me updates</span>
</div>
<input type="submit" value="Register" />
<a href="register.php" rel="login" class="linkform">You have an account already? Log in here</a>
<div class="clear"></div>
</div>
</form>
<form class="login active">
<h3>Login</h3>
<div>
<label>Username:</label>
<input type="text" />
<span class="error">This is an error</span>
</div>
<div>
<label>Password: <a href="forgot_password.php" rel="forgot_password" class="forgot linkform">Forgot your password?</a></label>
<input type="password" />
<span class="error">This is an error</span>
</div>
<div class="bottom">
<div class="remember"><input type="checkbox" /><span>Keep me logged in</span></div>
<input type="submit" value="Login"></input>
<a href="index.php" rel="register" class="linkform">You don't have an account yet? Register here</a>
<div class="clear"></div>
</div>
</form>
<form class="forgot_password">
<h3>Forgot Password</h3>
<div>
<label>Username or Email:</label>
<input type="text" />
<span class="error">This is an error</span>
</div>
<div class="bottom">
<input type="submit" value="Send reminder"></input>
<a href="index.php" rel="login" class="linkform">Suddenly remebered? Log in here</a>
<a href="register.php" rel="register" class="linkform">You don't have an account? Register here</a>
<div class="clear"></div>
</div>
</form>
</div>
<div class="clear"></div>
</div>
</div>
<!-- The JavaScript -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
//the form wrapper (includes all forms)
var $form_wrapper = $('#form_wrapper'),
//the current form is the one with class active
$currentForm = $form_wrapper.children('form.active'),
//the change form links
$linkform = $form_wrapper.find('.linkform');
//get width and height of each form and store them for later
$form_wrapper.children('form').each(function(i){
var $theForm = $(this);
//solve the inline display none problem when using fadeIn fadeOut
if(!$theForm.hasClass('active'))
$theForm.hide();
$theForm.data({
width : $theForm.width(),
height : $theForm.height()
});
});
//set width and height of wrapper (same of current form)
setWrapperWidth();
/*
clicking a link (change form event) in the form
makes the current form hide.
The wrapper animates its width and height to the
width and height of the new current form.
After the animation, the new form is shown
*/
$linkform.bind('click',function(e){
var $link = $(this);
var target = $link.attr('rel');
$currentForm.fadeOut(400,function(){
//remove class active from current form
$currentForm.removeClass('active');
//new current form
$currentForm= $form_wrapper.children('form.'+target);
//animate the wrapper
$form_wrapper.stop()
.animate({
width : $currentForm.data('width') + 'px',
height : $currentForm.data('height') + 'px'
},500,function(){
//new form gets class active
$currentForm.addClass('active');
//show the new form
$currentForm.fadeIn(400);
});
});
e.preventDefault();
});
function setWrapperWidth(){
$form_wrapper.css({
width : $currentForm.data('width') + 'px',
height : $currentForm.data('height') + 'px'
});
}
/*
for the demo we disabled the submit buttons
if you submit the form, you need to check the
which form was submited, and give the class active
to the form you want to show
*/
$form_wrapper.find('input[type="submit"]')
.click(function(e){
e.preventDefault();
});
});
</script>
</body>
</html>
Hopelijk kan hier iemand het oplossen...
Jules
Het klopt idd dat ik de was vergeten. Maar het werkt nog steeds niet.
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
/*
for the demo we disabled the submit buttons
if you submit the form, you need to check the
which form was submited, and give the class active
to the form you want to show
*/
$form_wrapper.find('input[type="submit"]').click(function(e){
e.preventDefault();
});
for the demo we disabled the submit buttons
if you submit the form, you need to check the
which form was submited, and give the class active
to the form you want to show
*/
$form_wrapper.find('input[type="submit"]').click(function(e){
e.preventDefault();
});
Het is wel handig als je dat uitcommentarieert
Gewijzigd op 25/11/2012 14:56:56 door Frits Katoen
Wanneer ik nu op register druk, wordt de pagina herladen en worden alle ingevulde gegevens in die URL erbij gezet, dus index.php?voornaam=jules enz.
Op een of andere manier worden de gegevens dus niet weggeschreven naar de database. Weet iemand misschien waar de fout zit?
<form method="post" class="register active" name="register" action="">
Gewijzigd op 28/11/2012 14:07:20 door Kris Peeters
werk prima, bedankt!