hi
is there a way of doing the else before the if i think i have seen something like it before.
if not how do i know what else is going with what if as i want the if to carry on but all the elses to come at the end
thanks reece
hope someone can help
else before if (i ment !)
Moderator: General Moderators
else before if (i ment !)
Last edited by reecec on Sat Jan 27, 2007 11:02 am, edited 1 time in total.
hi
Code: Select all
<?
if ($new==$new1) {
// search database to check for user
$request = "SELECT * FROM registered_members WHERE username='$cookie'";
// hand over the request
$results = mysql_query($request);
$rows = mysql_query($results);
$oldpasswordstored = $rows['password'];
$flag="OK"; // This is the flag and we set it to OK
$msg=""; // Initializing the message to hold the error messages
if(strlen($new) < 4){ // checking the length of the entered userid and it must be more than 5 character in length
$msg=$msg."( Please enter password more than 5 character length )<BR>";
$flag="NOTOK"; //setting the flag to error flag.
}
if($flag <>"OK"){
echo "<center>$msg <br> <input type='button' value='Retry' onClick='history.go(-1)'></center>";
}
else
{ // all entries are correct and let us proceed with the database checking etc …
// strip away any dangerous tags
$user=strip_tags($user);
$old=strip_tags($old);
// remove spaces from variables
$user=str_replace(" ","",$user);
$old=str_replace(" ","",$old);
// remove escaped spaces
$user=str_replace("%20","",$user);
$old=str_replace("%20","",$old);
// add slashes to stop hacking
$user=addslashes($user);
$old=addslashes($old);
// hash users password for security (32 chars random - md5)
$pass=md5($pass);
$old=md5($old);
if ($oldpasswordstored==$old) {
// Insert data into database
$sql="UPDATE registered_members(password=$pass)";
$result=mysql_query($sql);
}}
else
{
echo "The 2 Passwords you entered did not match please retry or this is not your old password";
}
?>i want an else for the $new==$new1
and an else for the $oldpasswordstored==$old
but the if the if is correct i want it to carry on
i think im thinking of this to hard and just cant see where to add it
thanks for you reply
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
The following is indented and has a few added bits that mark the ends of each if and I tried to add the brace needed for your last else.
I seriously suggest using an editor that has, at minimum, brace/bracket/paren matching.
I seriously suggest using an editor that has, at minimum, brace/bracket/paren matching.
Code: Select all
if ($new==$new1)
{
// search database to check for user
$request = "SELECT * FROM registered_members WHERE username='$cookie'";
// hand over the request
$results = mysql_query($request);
$rows = mysql_query($results);
$oldpasswordstored = $rows['password'];
$flag="OK"; // This is the flag and we set it to OK
$msg=""; // Initializing the message to hold the error messages
if(strlen($new) < 4)
{ // checking the length of the entered userid and it must be more than 5 character in length
$msg=$msg."( Please enter password more than 5 character length )<BR>";
$flag="NOTOK"; //setting the flag to error flag.
} // if(strlen($new) < 4)
if($flag <> "OK")
{
echo "<center>$msg <br> <input type='button' value='Retry' onClick='history.go(-1)'></center>";
} // if($flag <> "OK")
else
{ // all entries are correct and let us proceed with the database checking etc …
// strip away any dangerous tags
$user=strip_tags($user);
$old=strip_tags($old);
// remove spaces from variables
$user=str_replace(" ","",$user);
$old=str_replace(" ","",$old);
// remove escaped spaces
$user=str_replace("%20","",$user);
$old=str_replace("%20","",$old);
// add slashes to stop hacking
$user=addslashes($user);
$old=addslashes($old);
// hash users password for security (32 chars random - md5)
$pass=md5($pass);
$old=md5($old);
if ($oldpasswordstored==$old)
{
// Insert data into database
$sql="UPDATE registered_members(password=$pass)";
$result=mysql_query($sql);
} // if ($oldpasswordstored==$old)
}
} // if ($new==$new1)
else
{
echo "The 2 Passwords you entered did not match please retry or this is not your old password";
}-
mmcoolkid94
- Forum Newbie
- Posts: 8
- Joined: Mon Jun 19, 2006 9:07 pm