Wachtwoord Veranderen
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
<?php
include 'mysql.php';
if(isset($_SESSION['Username'])){
$Password = $_POST['Password'];
$Newpassword = $_POST['Newpassword'];
$VNewPassword = $_POST['VNewPassword'];
$result = mysql_query("SELECT Password FROM accounts WHERE Username='$_SESSION['Username']'");
if(!$result)
{
echo "The session does not exist";
}
else
if($Password!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
}
if($NewPassword=$VNewPassword)
$sql=mysql_query("UPDATE accounts SET Password='$NewPassword' where Username='$_SESSION['Username']'");
if($sql)
{
echo "Password is changed!";
}
else
{
echo "Password field and the verify password field are not the same";
}
}
?>
include 'mysql.php';
if(isset($_SESSION['Username'])){
$Password = $_POST['Password'];
$Newpassword = $_POST['Newpassword'];
$VNewPassword = $_POST['VNewPassword'];
$result = mysql_query("SELECT Password FROM accounts WHERE Username='$_SESSION['Username']'");
if(!$result)
{
echo "The session does not exist";
}
else
if($Password!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
}
if($NewPassword=$VNewPassword)
$sql=mysql_query("UPDATE accounts SET Password='$NewPassword' where Username='$_SESSION['Username']'");
if($sql)
{
echo "Password is changed!";
}
else
{
echo "Password field and the verify password field are not the same";
}
}
?>
wat gaat hier mis?
Toevoeging op 13/09/2012 17:14:45:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\project space\changepassword.php on line 12
dat is de error die ik krijg
Gewijzigd op 13/09/2012 17:14:03 door Niels Peeren
Code (php)
1
$result = mysql_query("SELECT Password FROM accounts WHERE Username='".$_SESSION['Username']."'");
lijn zijn overigens overbodig. Je hebt die POST-variabelen toch al?
Dankuwel voor de snelle reactie en dat was inderdaad het probleem ik heb nu alleen nog een andere probleem , Parse error: syntax error, unexpected $end in C:\xampp\htdocs\project space\changepassword.php on line 35 wat houdt dit in?
Er mis een accoalde { en }, dus tel ze maar even na.
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
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
<?php
include 'mysql.php';
if(isset($_SESSION['Username'])){
$Password = $_POST['Password'];
$Newpassword = $_POST['Newpassword'];
$VNewPassword = $_POST['VNewPassword'];
$result = mysql_query("SELECT Password FROM accounts WHERE Username='".$_SESSION['Username']."'");
if(!$result)
{
echo "The session does not exist";
}
else
if($Password!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
}
if($NewPassword=$VNewPassword){
$sql=mysql_query("UPDATE accounts SET Password='$NewPassword' WHERE Username='".$_SESSION['Username']."'");
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
}
else
{
echo "The new password and confirm new password fields must be the same";
}
?>
include 'mysql.php';
if(isset($_SESSION['Username'])){
$Password = $_POST['Password'];
$Newpassword = $_POST['Newpassword'];
$VNewPassword = $_POST['VNewPassword'];
$result = mysql_query("SELECT Password FROM accounts WHERE Username='".$_SESSION['Username']."'");
if(!$result)
{
echo "The session does not exist";
}
else
if($Password!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
}
if($NewPassword=$VNewPassword){
$sql=mysql_query("UPDATE accounts SET Password='$NewPassword' WHERE Username='".$_SESSION['Username']."'");
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
}
else
{
echo "The new password and confirm new password fields must be the same";
}
?>
Toevoeging op 13/09/2012 17:25:43:
okay zal ik even doen
Toevoeging op 13/09/2012 17:28:34:
ik heb nu geen error meer. ik krijg nu in witte lege pagina zonder tekst dus en in de database wordt niks aangepast
Hij geeft nog steeds geen error aan beetje raar
Verder debuggen, gooi op logische wijze wat echo's in je code zodat je weet wat er gebeurt.
Toevoeging op 13/09/2012 18:34:58:
ik heb even gegeten maar het blijkt achteraf toch niet te werken. de pagina blijft nog steeds wit zonder bericht en ik heb al wat geprobeerd met echo's op meerdere plekken en toch geen verandering.
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
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
<?php
session_start();
$error=0;
error_reporting(E_ALL);
ini_set("display_errors",1);
include 'mysql.php';
if(isset($_SESSION['Username'])){
$OldPassword = $_POST['OldPassword'];
$NewPassword = $_POST['NewPassword'];
$VNewPassword = $_POST['VNewPassword'];
$result = mysql_query("SELECT Password FROM accounts WHERE Username='".$_SESSION['Username']."'");
if(!$result)
{
echo "The session does not exist";
}
else
if($OldPassword!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
$error ++;
}
if($error !=0){
if($NewPassword==$VNewPassword){
$sql=mysql_query("UPDATE accounts SET Password='$NewPassword' WHERE Username='".$_SESSION['Username']."'");
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
}
else
{
echo "The new password and confirm new password fields must be the same";
echo "error = $error Password = $NewPassword VNewPassword = $VNewPassword Username = $Username";
}
}
}
?>
session_start();
$error=0;
error_reporting(E_ALL);
ini_set("display_errors",1);
include 'mysql.php';
if(isset($_SESSION['Username'])){
$OldPassword = $_POST['OldPassword'];
$NewPassword = $_POST['NewPassword'];
$VNewPassword = $_POST['VNewPassword'];
$result = mysql_query("SELECT Password FROM accounts WHERE Username='".$_SESSION['Username']."'");
if(!$result)
{
echo "The session does not exist";
}
else
if($OldPassword!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
$error ++;
}
if($error !=0){
if($NewPassword==$VNewPassword){
$sql=mysql_query("UPDATE accounts SET Password='$NewPassword' WHERE Username='".$_SESSION['Username']."'");
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
}
else
{
echo "The new password and confirm new password fields must be the same";
echo "error = $error Password = $NewPassword VNewPassword = $VNewPassword Username = $Username";
}
}
}
?>
Toevoeging op 13/09/2012 18:41:10:
oh ik zie het al de $error !=0 vergelijking moest $error ==0 zijn zonder uitroepteken en met dubbele =