Forum Moderators: coopster
<? $sql="SELECT * FROM members WHERE login='".md5($_POST['login'])."' AND passwd='".md5($_POST['password'])."'";
$qry=mysql_query($sql);
$result=mysql_fetch_array($qry);
if($result['count']>=3) {
echo "<input name="Submit" type="submit" value="Finish" />";
}else{
<input type="button" name="post" class="FormInput2" value="Submit" onclick="popup(); "/>
}
</p>
?>
<?php
$sql="SELECT * FROM members WHERE login='".md5($_POST['login']).
"' AND passwd='".md5($_POST['password'])."'";
$qry=mysql_query($sql);
$result=mysql_fetch_array($qry);
$form ='<form action="some-script.php">';
if($result['count']>=3) {
$form .= '<input name="Submit" type="submit" value="Finish">';
}
else{
for ($i=0;$i<=3;$i++) {
// whatever you pass into popup() for the 3 states, use the value of
// $buttonname in some-script.php to do whatever you do in popup(),
// for example, to parse $buttonname to return $this_url
$buttonname = 'button_' . $i;
$this_url = 'whatever_' . $i . '.html';
$form .= '
<input type="hidden" name="' . $buttonname . '" value="' . $i . '">
<input type="submit" name="' . $buttonname .
'" class="FormInput2" value="Submit" onclick="return popup(\'' . $this_url . '\');">';
}
}
$form .= '</form>
<script type="text/javascript">
function popup(url) {
var day = new Date();
var id = day.getTime();
var params="width=500,height=500,scrollbars,resizable";
var win = open (url,id,params);
return false;
}
</script>
';
echo $form;
?>
This still has a problem, though, if the user presses enter, only the first button in the source code will be triggered (or none at all.) Generally you put the event handlers on the form, not the button, to handle this case, so you'll need somethign on the form to manage it, like
$form ='<form action="some-script.php" onsubmit="return some_function(this);">';
But not knowing the full scope, not sure what help to offer there . . .
Or, you are just saying . . . this limits login attempts? If so,
<?php
$sql="SELECT * FROM members WHERE login='".
md5($_POST['login'])."' AND passwd='".md5($_POST['password'])."'";
$qry=mysql_query($sql);
$result=mysql_fetch_array($qry);
$form ='<form action="some-script.php">';
if($result['count']>=3) {
$form .= '<input name="Submit" type="submit" value="Finish">';
}
else{
$form .=
<input type="submit" name="post" class="FormInput2" value="' .
Login attempt number ' . $result['count'] . '" onclick="return popup();">';
}
}
$form .= '</form>';
echo $form;
?>
So from the pop up window, you can access any elements or functions in the window.opener like so:
if (window.opener) {
window.opener.document.location='http://www.example.com';
window.close();
}
The above would direct the parent to example.com then close the pop up.
Curious, what were you trying to do?