PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
fullyloaded
Forum Newbie
Posts: 3 Joined: Sat Nov 05, 2011 5:25 pm
Post
by fullyloaded » Sun Feb 26, 2012 2:59 am
hi
i was wondering if anyone had any idea how to fix the error in my code? the problem im having is this message is showing before i do anything on my page (Old password incorrect. please try again.) but other then that the code is work thanks...
Code: Select all
<?PHP
$reqlevel = 1;
include("membersonly.inc.php");
if ($allowChangePassword == false){die($disabledFeatures);}
$oldpass1 = hash('sha512', $_POST['oldpass']);
$password1 = hash('sha512', $_POST['password']);
$password2 = hash('sha512', $_POST['password2']);
if ($password1 == $password2 && $password1 <> ""){
$query = "Select * from ".$DBprefix."signup where username='$user_currently_loged' And password='$oldpass1'";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result)){
$query = "UPDATE ".$DBprefix."signup Set password = '$password1' where username='$user_currently_loged'";
$result = mysql_query($query);
$_SESSION["pass"] = $password1;
makeform("You password was changed.");
}else{
makeform("Old password incorrect. please try again.");
}
}else{
if ($password1 == ""){makeform("");}
else{makeform("Your password do not match try again.");}
}
function makeform($errormessage){
?>
Code: Select all
<?PHP echo "<font color=\"#FF0000\"><strong>$errormessage</strong></font>";?>
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Sun Feb 26, 2012 7:11 am
You aren't checking if the form has been submitted, you're jumping right to this:
Code: Select all
if ($password1 == $password2 && $password1 <> "")
fullyloaded
Forum Newbie
Posts: 3 Joined: Sat Nov 05, 2011 5:25 pm
Post
by fullyloaded » Mon Feb 27, 2012 3:20 pm
hi
thanks for the reply how would i go about fixing this i tried a lot of things with no luck i still have a lot to learn in php thanks...
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Mon Feb 27, 2012 3:23 pm
a common method of checking for a submitted form is this
Code: Select all
<?php
if (isset($_POST['submitButtonName'])) {
// process form
}
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering