...

View Full Version : else...else...if



Deacon Frost
05-15-2008, 07:38 AM
Hey guys, long time no see. I stopped programming for a couple of months, and now I'm really fuzzy and can't even fix up a nice password change form O.o. Anyways, I'm having issues setting it up, here's my current code, and my issue at the bottom...




<?

$url = $_GET['$password'];
$oldpass = $_GET["oldpassword"];
$newpass = $_POST["newpassword"];
$newpass2 = $_POST["newpassword2"];

if(isset($password) && isset($newpass))
{
echo "".$oldpass.",".$newpass.",".$newpass2.".";
}

?>

<?

elseif(isset($password) && !isset($newpass))

{
?>

<form action="?password=<? echo $newpass ?>" method="post" ?>
Please enter your old password:<br /> <input type="password" name="oldpassword" /><br /><br />
Please enter your new password:<br /> <input type="password" name="newpassword" /><br /><br />
Please confirm your new password:</br /> <input type="password" name="newpassword2" /><br /><br />
<input type="submit" value="Change Password">
</form>

<?
}

else
{
?>
<div id="content">
<h2><a href"?password=">Change Password</a></h2>

<?
}
?>


E: Oh Yeah:

My Error = Parse error: syntax error, unexpected T_ELSEIF in accoptions.php on line 21



Now, what I want, it should display the Change Password thing at the bottom (The 'Else' option) if every other criteria is not met. If you have clicked it, it should display the elseif option, and if you have changed everything, it should echo just the data (I haven't attached the database to it yet, so it's not updating).


Thanks in advance :D.

abduraooft
05-15-2008, 09:00 AM
if(isset($password) && isset($newpass))
{
echo "".$oldpass.",".$newpass.",".$newpass2.".";
}

?>

<?

elseif(isset($password) && !isset($newpass))

{
Hmm.. there is an independent block inside the first if and elseif, which is not allowed.

However the following should work!


if(isset($password) && isset($newpass))
{
echo "".$oldpass.",".$newpass.",".$newpass2.".";


?>

<?
}
elseif(isset($password) && !isset($newpass))

{

Deacon Frost
05-15-2008, 09:06 AM
Nope, no such luck.


http://downstage.tv/accoptions.php


It got rid of the error, now it just won't read it?

Checking out what that's all about, but still having issues :P.

abduraooft
05-15-2008, 09:12 AM
OK, but what's this
if(isset($password) && isset($newpass))

Deacon Frost
05-15-2008, 09:15 AM
Oh, I didn't see that. It was off, but didn't fix the issue.



<?

$url = $_GET["password"];
$oldpass = $_GET["oldpassword"];
$newpass = $_POST["newpassword"];
$newpass2 = $_POST["newpassword2"];

if(isset($url) && isset($newpass))
{
echo "".$oldpass.",".$newpass.",".$newpass2.".";

}
elseif(isset($url) && !isset($newpass))

{
?>

<form action="?password=<? echo $newpass ?>" method="post" ?>
Please enter your old password:<br /> <input type="password" name="oldpassword" /><br /><br />
Please enter your new password:<br /> <input type="password" name="newpassword" /><br /><br />
Please confirm your new password:</br /> <input type="password" name="newpassword2" /><br /><br />
<input type="submit" value="Change Password">
</form>

<?
}

else
{
?>
<h2><a href"?password=">Change Password</a></h2>

<?
}
?>


Is the edited code.

abduraooft
05-15-2008, 09:23 AM
Are you trying to display a form in that page by the above code?
I don't think the above code is enough for that.
If if(isset($url) && isset($newpass)) is false, then

elseif(isset($url) && !isset($newpass)) also be false.

And what's this

<a href"?password=">Change Password</a>?
Firebug shows it like

<a footer="" ?password=">Change Password</a>

Deacon Frost
05-15-2008, 09:33 AM
I want it to display a link to click to change the page to a form to change the page to the data entered in the form.

E: It sucks with things are so simple. Hence why we code during day time, and not at 2a.m..


Thanks man! Got it fixed now, and tweaked it. I think I'm back in the groove, sometimes it just takes an outside input.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum