first I have to use PHP4 and SMARTY2. Yep I know it is very bad :-/ but we're unable to upgrade cause the existing systems need that environment... :@
I want to code a admin login with jquery's load and php. There is a 3 part Login cause of the tpl system of smarty: a smarty login (with php and tpl) a forgotten php and another login php. I can only load php with jquery: not tpl and php
- the first login is include in our frame.tpl
- the other 2 can only used with a combination of php and html cause of the load()
I can't get the POSTs from the combinatet php's could u pls tell me how I can use it?
so here the code where i include the login.tpl:
<div id='rightcolumn'>
<div class='admin'>
<h3>ADMINISTRATOR</h3>
{include file='login.tpl'}
</div>
the login.tpl
<form method="POST">
{literal}
<script type="text/javascript">
$(document).ready(function(){
$("#load").click(function(){
$("#dynamic").load("././content/pw_lost.php");
return false;
});
});
</script>
{/literal}
<br />
<div id="dynamic">
<!--[if IE]>
Pers.Nr.:
<br /><input type="text" name="persnr" style="width:150px;" value="Pers.Nr."
onfocus="if(this.value==this.defaultValue)this.value='';"
onblur="if(this.value=='')this.value=this.defaultValue;"/>
<br />
<br />
Passwort:
<br /><input type="password" name="password" style="width:150px;" value="***********"
onfocus="if(this.value==this.defaultValue)this.value='';"
onblur="if(this.value=='')this.value=this.defaultValue;"/>
<br />
<br /><input type="submit" name="login" value="anmelden" />
<![endif]-->
<!--[if !IE]> -->
<fieldset id="inputs" class="field_login">
<input id="persnr" name="persnr" type="text" placeholder="Pers.Nr.">
<input id="password" name="password" type="password" placeholder="Password">
</fieldset>
<br />
<button type="submit" name="login" value="anmelden" class="myButton">Anmelden</button>
<br />
<!--<![endif]-->
<br />
<br /><div id="load"><a href="" class="loadlink">Passwort vergessen?</a></div>
<br />
<br />
</div>
</form>
here the forgotten.php: and here is the problem I can't use the php block (if I don't use the first if(isset()) i get a blank page... and if i submit the whole page is reloading and didn't get any POSTs
<?php
if(isset($_POST['persnr'])) {
if (empty($_POST['persnr'])) {
$SMARTY->assign('message', 'Bitte füllen Sie alle Felder aus.');
} else {
$TMP_PERSNR = strtolower($DB->escape($_POST['persnr']));
$query = "SELECT * FROM TAB_MITARBEITER WHERE lower(NPERSNR)='$TMP_PERSNR'";
$res = $DB->query($query, TRUE);
unset($query);
if ($res) {
// also wenn es den Mitarbeiter gibt
$pool = "qwertzupasdfghkyxcvbnm";
$pool .= "23456789";
$pool .= "WERTZUPLKJHGFDSAYXCVBNM";
srand ((double)microtime()*1000000);
for($index = 0; $index < 8; $index++) {
$newpassword .= substr($pool,(rand()%(strlen ($pool))), 1);
}
$Name = "SAZ Support"; //senders name
$email = $res[0]['VCMAIL']; //senders e-mail adress
$recipient = $res[0]['VCMAIL']; //recipient
$subject = "SAZ - neues Passwort"; //subject
$header = "From: ". $Name . " <" . ">
"; //optional headerfields
$mail_body = ucfirst(strtolower($res[0]['VCNAME'])) ." ". ucfirst(strtolower($res[0]['VCVORNAME'])) . ",
";
$mail_body .= "gerne möchten wir Ihnen ein neues Passwort zusenden. Ihr neues Passwort lautet: $newpassword
";
$mail_body .= "Sie können Ihr Passwort jederzeit unter 'Einstellungen' in der SAZ ändern.
";
$mail_body .= "Wenn Sie kein neues Passwort angefordert haben und Sie glauben, dass es sich um Missbrauch der Funktion handelt, dann wenden Sie sich bitte mit dieser E-Mail an die Systemadministration.
";
$mail_body .= "Mit freundlichen Grüßen
";
$mail_body .= "Ihr SAZ Support
";
$mail_body .= "
";
$mail_body .= "Abfrage von folgender Maschine gestartet: {$_SERVER['REMOTE_ADDR']}
";
// change pw:
$newpassword = md5($newpassword);
$query = "UPDATE TAB_MITARBEITER SET VCPASSWORT='$newpassword' WHERE lower(NPERSNR)='$TMP_PERSNR'";
$res = $DB->query($query, FALSE);
unset($query);
if (mail($recipient, $subject, $mail_body, $header) === TRUE) {
$SMARTY->assign('message', 'Passwort zugesendet.');
}
} else {
$SMARTY->assign('message', 'Fehler. Mitarbeiter nicht gefunden.');
}
}
}
?>
//HTML starts
<form method="POST">
<script type="text/javascript">
$(document).ready(function(){
$("#load").click(function(){
$("#dynamic").load("././content/2_login.php");
return false;
});
});
</script>
<div id='dynamic'>
<div id='justify'>
Wenn Sie ihr Passwort vergessen haben, oder Sie noch kein Passwort vergeben haben, dann geben Sie hier bitte Ihre Personalnummer ein und wir senden ihnen per Email umgehend ein (neues) Passwort zu (sofern ein Benutzer für Sie bereits angelegt wurde).<br /><br />
</div>
Pers.Nr:
<br />
<input type="text" name="persnr">
<br />
<br />
<input type="submit" name="lostpw" value="Passwort anfordern" />
<br />
<br />
<div id="load"><a href="" class="loadlink">Ich möchte mich einloggen.</a></div>
</div>
</form>