Skip to content | Skip to navigation
Jun 22, 2006 16:04 # 43132
ginsterbusch *** (5) isn't happy...
Hi,
thanks for listening. I'm getting mad with some simple password recovery-script of mine.
It simply shall look up a user name, and if its found, generate a new password, dump it into the database and send it to the owner, too. When I'm letting the script run, it always complains about some unexpected brackets, T_CASES, etc. I've checked all the bloody brackets, the switch-cases and even the mysql-queries, but to no avail - the script simply won't run.
So here we go - I'm posting the relevant stuff only (anything else works fine, like the header output etc.):
<div id="page-wrap">
<? include('inc/prybar.php'); ?>
<div id="main">
<h2><? echo $_page_title; ?></h2>
<? switch(empty($_POST['pw_lost_login'])) {
case false: // generate new password, save it to the db and send it to the user, too
// check if username exists at all
$check = mysql_query(
'SELECT user_id, user_login, user_email FROM saf_userbase WHERE user_login = '
. clean_mysql_var($_POST['pw_lost_login'])
. ' LIMIT 1'
, $link
);
$check_row = mysql_fetch_array($check);
if($check != false && mysql_num_rows($check) > 0) {
$new_pw = get_random_pwd(7);
$update = mysql_query (
"UPDATE saf_userbase SET user_pw = '".md5($new_pw)."' WHERE user_id = ".$check_row['user_id'].' LIMIT 1'
, $link
);
if($update != false) {
$msg = "Willkommen zurueck bei Search and Find!\n"
."Sie haben ein neues Passwort angefordert.\n\n"
."Neues Passwort: ".md5($new_pw)."\n\n"
."In Ihrem Profileinstellungen koennen Sie es aendern.\n\n"
."Noch viel Erfolg mit Ihrem Account bei SaF,\n\n"
."das SaF-Team.";
$mail_sent = mail (
$check_row['user_email']
, 'Search and Find: Neues Passwort'
, $msg
, "From: bounce@somedomain.de\nX-Mailer: saf-password-recovery/0.1"
);
/*if($mail_sent != true) {
exit('<p>Aus unbekanntem Grund konnte die Mail mit Ihrem neuen Passwort nicht versendet werden. Bitte verständigen Sie den Webmaster!</p>')
}*/
?>
<p>Ihr neues Passwort wurde Ihnen soeben zugesandt.</p>
<p><a href="index.php">Zurück zur Startseite</a></p>
<? /*} else {
exit('<p>Datenbank-Fehler aufgetreten. MySQL-Datenbank meldet zurück:'.mysql_error().'<br />Bitte verständigen Sie den Webmaster!</p>')
}*/
} else { ?>
<p>Der Benutzername <strong><? echo clean_form_var($_POST['pw_lost_login']); ?></strong> konnte leider nicht gefunden werden. Versichern Sie sich, dass Sie ihn richtig eingegeben haben und versuchen Sie es dann nochmals:</p>
<form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
<p><span>Benutzer-Login:</span>
<input type="text" name="pw_lost_login" size="30" style="width: 200px" value="<? echo clean_form_var($_POST['pw_lost_login']); ?>" /></p>
<p><button type="submit">Neues Passwort anfordern</button></p>
</form>
<? }
break;
default: ?>
<p>Sie können sich nicht mehr an Ihr Passwort erinnern? Macht nichts. Geben Sie folgend bitte Ihren Benutzernamen ein, dann senden wir Ihnen automatisch ein neues an die in Ihrem Benutzeraccount angegebene E-Mail-Adresse:</p>
<form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
<p><span>Benutzer-Login:</span>
<input type="text" name="pw_lost_login" size="30" style="width: 200px" /></p>
<p><button type="submit">Neues Passwort anfordern</button></p>
</form>
<? break;
} ?>
</div>
</div>
I've probably went 'arbeitsblind', ie. 'work-shift blind'.
Any suggestions yet? What am I doing wrong?
Thanks in advance,
cu, w0lf.
ps: if this script looks kinda cut like it does on my workstation (SuSE 9, KDE 3.1, Firefox 1.5), you may take a look at it over here instead ;)
Multiple exclamation marks are a sure sign for a diseased mind!
This post was edited by ginsterbusch on Jun 22, 2006.
Jul 06, 2006 15:36 # 43246
ginsterbusch *** (5) replies...
Hello. Is this PHP5 or PHP4?
Running it with PHP5 gives me "unexpected T_DEFAULT" on line 59.
It's PHP 4, but I'm not using anything hyper-special PHP 4-functions inside the script.
That's nearly the same error I get when I'm trying to run this script. And I've checked it helluva lot times, over and over again and I cant find the fucking mistake X-(
Damn.
cu, w0lf.
Multiple exclamation marks are a sure sign for a diseased mind!
Jul 06, 2006 15:36 # 43247
WASABI *** (4) has all the information you need...
Ok, I've seen the problem. There IS a missing '{'. Problem is, matching tools (like the '%' key in vi) just scan and tell you it's ok, because you have enough opening brackets in your comments. I removed all comments, and the last bracket got matched by the one at
if($check != false && mysql_num_rows($check) > 0) {
Hope it helps :D
:wq
Jul 07, 2006 00:42 # 43253
ginsterbusch *** (5) smiles...
Ok, I've seen the problem. There IS a missing '{'. Problem is, matching tools (like the '%' key in vi) just scan and tell you it's ok, because you have enough opening brackets in your comments
Damn. I knew there was a glitch somewhere. I'm using Quanta Plus as replacement for my beloved Homesite under Linux, and it is offering this option, too.
Thanks a lot, man! Gonna fix this clumsy mistake ASAP and hope it'll work afterwards! ;)
cu, w0lf.
Multiple exclamation marks are a sure sign for a diseased mind!