i am working on a login Script. I have a registration and its login, what i need to give a single access/login, i have my fields in database table name is qz_userauth as ID fname lname email username password. Restrict login after one attempt. Possible ?
Here is login Form
<form action="functions.php" method="post" id="login">
<fieldset>
<legend>Login </legend>
<ul>
<li>
<label for="username"><span class="required">Username</span></label>
<input id="username" name="username" class="text required" type="text" />
<label for="username" class="error">This field cannot be empty</label>
</li>
<li>
<label for="password"><span class="required">Password</span></label>
<input name="password" type="password" class="text required" id="password" maxlength="20" />
</li>
<?php if($_SESSION['LCNT']>=4){ ?>
<li>
<p id="p-captcha">
<div id="captchaImg"><img id="captcha" src="captcha/securimage_show.php" alt="CAPTCHA Image" /></div>
<div id="captchaInput"><input type="text" name="captcha_code" size="16" maxlength="6" value="Enter Captcha" /></div>
<div id="captchaRefresh"><img src="captcha/images/refresh.gif" /></div>
</p>
</li>
<?php } ?>
<li>
<label class="centered info"><a id="forgotpassword" href="fpass.php">Forgot Your password...</a></label>
</li>
</ul>
</fieldset>
<input type="hidden" name="action" value="login" />
<fieldset class="submit">
<input type="submit" class="sbutton" value="Login" /> <input type="button" class="sbutton" value="Register" onclick="window.location='register.php'" />
</fieldset>
</form>
Just set one more field in the table as flag. and after one login attempt set the value of flag as false. and check the flag value during login.
If you mean to ask you want to allow only 1 login at a time per user then you can add another field to your table something like login_status. Set this to 1 when user is logged in and 0 on logout. Then in your login script check if this is 0, only then allow login
Related
I'm using the PHPmotion script: http://demo.phpmotiontemplates.com/default/
and I've succeeded in getting the Log-In Form (on the home page) to disappear, once it successfully performs it's function, (which is what I'm trying to accomplish), but as soon as the Log-In function succeeds, and the "sub-menu" on the home page appears,
the Log-In Form reappears again (on the homepage).
So, I'm assuming the sub-menu has something to do with the Log-In Form reappearing.
Which looks like this:
<form action="../login.php" method="post" accept-charset="UTF-8" class="middletext"
onsubmit="javascript:this.style.display='none';">
<p>
<input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value=='ENTER USERNAME') {this.value=''; this.style.color='#696969';}" >
<input type="text" size="20" name="password_login" id="password_login" value="ENTER PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value=='ENTER PASSWORD') {this.value=''; this.style.color='#696969';}" >
<input type="hidden" name="cookie_time" value="10080" />
<img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit" style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" />
<input type="hidden" name="submitted" value="yes" />
<input type="hidden" name="remember_me" value="remember_me" />
</p>
</form>
</div>
<!--Begin Sub-Navigation. This only appears when a user is logged in.-->
<div class="container1">
<div class="menu1">
<div class="sub-nav"> <img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /> my account<img src="../themes/default/images/arrow- red.jpg" style="vertical-align:middle" alt="" />
[var.lang_my_credits]: [var.member_credits]</font><img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle">[var.login_out]
<!--[onload;block=div;when [var.loggedin]=1;comm]-->
</div>
Any thoughts/solution about this will be greatly appreciated.
<?php
if(!isset($_SESSION['YOUR-SESSION-NAME'])){
echo '<form action="../login.php" method="post" accept-charset="UTF-8" class="middletext"
onsubmit="javascript:this.style.display=\'none\';">
<p>
<input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value==\'ENTER USERNAME\') {this.value=\'\'; this.style.color=\'#696969\';}" >
<input type="text" size="20" name="password_login" id="password_login" value="ENTER PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value==\'ENTER PASSWORD\') {this.value=\'\'; this.style.color=\'#696969\';}" >
<input type="hidden" name="cookie_time" value="10080" />
<img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit" style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" />
<input type="hidden" name="submitted" value="yes" />
<input type="hidden" name="remember_me" value="remember_me" />
</p>
</form>
</div>
<!--Begin Sub-Navigation. This only appears when a user is logged in.-->
<div class="container1">
<div class="menu1">
<div class="sub-nav"> <img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /> my account<img src="../themes/default/images/arrow- red.jpg" style="vertical-align:middle" alt="" />
[var.lang_my_credits]: [var.member_credits]</font><img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle">[var.login_out]
<!--[onload;block=div;when [var.loggedin]=1;comm]-->
</div>';
} else {
echo 'You\'re already logged in!';
}
?>
I have just discovered that the isset function is no longer working on my login and register forms. Very strange I though, so I undid everything that I had recently done to see if it was causing it but no luck. If i remove the isset and replace with this;
if($_SERVER['REQUEST_METHOD'] == "POST"){
it works! But I have two forms on one page so I need to check which one is submitted.
Here's the isset function:
if (isset($_POST['submit_login'])) {
And the submit button just so you know it has the correct name;
<input type="submit" name="submit_login" value="Login" class="buttonClassic"/>
The one for the register form is exactly the same but with name submit_reg.
Form:
<form action="<?php echo htmlentities('Login'); ?>" method="post" id="login">
<p class="p1">Already signed up? Log in</p><hr/>
<label for="email">Your email address </label><input type="email" required name="email" placeholder="Email" class="text" id="email">
<label for="password">Your password </label><input type="password" name="pass" required placeholder="Password" class="text" id="password">
<center><input type="submit" name="submit_login" value="Login" class="buttonClassic"/></center>
<div class="center-align-text">
<p class="p3">Forgotten your password?</p>
</div>
</form>
reg form:
<form action="<?php echo htmlentities('Login'); ?>" method="post" id="register" >
<p class="p1">New to NBS? Sign up, it's free!</p><hr/>
<label for="reg_email">What's your email address? </label><input type="email" name="email" required placeholder="Email" class="text" id="reg_email">
<label for="reg_password">Choose a password </label><input type="password" required name="pass" placeholder="Password" class="text" id="reg_password">
<label for="reg_password2">Re-type password </label><input type="password" required name="pass2" placeholder="Re-type password" class="text" id="reg_password2">
<input type="checkbox" name="subscribed" value="subscribed" id="subscribed"><label for="subscribed">Yes, send me email updates from NewBorn Sounds. </label>
<br/>
<input type="checkbox" required="flag" name="terms" value="ticked" id="terms"><label for="terms">I agree to the terms & conditions.</label>
<center><input type="submit" name="submit_reg" value="Sign Up" class="buttonClassic"></center>
</form>
If you need anything more just shout!
Oh and I know I could just submit the form to an external PHP script but I don't particularly want to do that as I would like the user input errors to be outputted to the same page. I know I could just use ajax, which I do, but I am trying to keep javascript as an add-on and not reduce the user experience for no js.
Full HTML:
<div id="login_form_wrapper">
<form action="Login" method="post" id="login" novalidate="novalidate">
<p class="p1">Already signed up? Log in</p><hr>
<label for="email">Your email address </label><input type="email" required="" name="email" placeholder="Email" class="text" id="email">
<label for="password">Your password </label><input type="password" name="pass" required="" placeholder="Password" class="text" id="password">
<center><input type="submit" name="submit_login" value="Login" class="buttonClassic"></center>
<div class="center-align-text">
<p class="p3">Forgotten your password?</p>
</div>
</form>
<form action="Login" method="post" id="register" novalidate="novalidate">
<p class="p1">New to NBS? Sign up, it's free!</p><hr>
<label for="reg_email">What's your email address? </label><input type="email" name="email" required="" placeholder="Email" class="text" id="reg_email">
<label for="reg_password">Choose a password </label><input type="password" required="" name="pass" placeholder="Password" class="text" id="reg_password">
<label for="reg_password2">Re-type password </label><input type="password" required="" name="pass2" placeholder="Re-type password" class="text" id="reg_password2">
<input type="checkbox" name="subscribed" value="subscribed" id="subscribed"><label for="subscribed">Yes, send me email updates from NewBorn Sounds. </label>
<br>
<input type="checkbox" required="flag" name="terms" value="ticked" id="terms"><label for="terms">I agree to the terms & conditions.</label>
<center><input type="submit" name="submit_reg" value="Sign Up" class="buttonClassic"></center>
</form>
</div>
maybe you could do something like this :
if($_SERVER['REQUEST_METHOD'] == "POST"){
if (isset($_POST['submit_login'])) {
//do something
} else {
//do something else
}
}
Form action needs to be a valid url, e.g. "/login.php".
Checkboxes have either the value given (once checked), or they do not appear at all. Best is to double check them: "isset($_POST['mycheckbox']) && 'value' ==$_POST['mycheckbox']".
Show us the php you use to evaluate the form.
How this?
<input type="submit" name="submit_reg" value="Sign Up" class="buttonClassic">
<?php
if($_POST['submit'] == 'Sign Up'){
//do something
}
?>
I have the following in a WordPress sidebar widget that serves as an online community for my niche. Right now I am able to display the form when the user is not logged in and to display the "Welcome to the Community!" message when the user is logged out -- which is great. However, the login functionality doesn't seem to be working. Could I please get some help?
<form name="loginform" id="loginform" action="https://domain.org/wp-login.php"
method="post">
<p class="login-username">
<label for="user_login">Username</label>
<input type="text" name="log" id="user_login" class="input" value=""
size="20" />
</p>
<p class="login-password">
<label for="user_pass">Password</label>
<input type="password" name="pwd" id="user_pass" class="input"
value="" size="20" />
</p>
<p class="login-submit">
<input type="submit" name="wp-submit" id="wp-submit" class="button-
primary" value="Log In" />
<input type="hidden" name="redirect_to"
value="https://domain.org/" />
</p>
</form>
<?php } else { ?>
<h4>Welcome to the Community!<h4>
<?php } ?>
try this...
if (!is_user_logged_in()) {
wp_login_form();
} else {
echo '<h4>Welcome to the Community!</h4>';
}
You can also pass a configuration array to wp_login_form() See http://codex.wordpress.org/Function_Reference/wp_login_form
I have two forms on a page-'indexpage plus a included page'. Their actions point as so action=''. The problem is when I hit submit on the search bar, it shows a header error. The submit for the login works fine. I narrowed the problem all the way down to
tabindex="6" type="submit"
in the submit button of the login form.
They both have different names.
Login Form:
echo'<div id="container">
<div id="topnav" class="topnav"> <font color="white">Have an account?  </font> <span>Sign in</span><span>Sign Up</span> </div>
<fieldset id="signin_menu">';
output_errors($errors);
echo'
<form id="signin" action="" method="POST" >
<br>
<label for="username"><font color="black">Username or email</font></label>
<input id="username" name="username" value="" title="username" tabindex="4" type="text">
</p>
<p>
<label for="password"><font color="black">Password</font></label>
<input id="password" name="password" value="" title="password" tabindex="5" type="password">
</p>
<p class="remember">
<input id="signin_submit" name="submit" value="Sign in" tabindex="6" type="submit">
<input id="remember" name="remember_me" value="1" tabindex="7" type="checkbox">
<label for="remember"><font color="black">Remember me</font></label>
</p>
<p class="forgot"> Forgot your password? </p>
<p class="forgot-username"> <A id=forgot_username_link
title="If you remember your password, try logging in with your email"
href="/recovery/username">Forgot your username?</A> </p>
</form>
</fieldset>
</div>';
Search Form:
<form action='' method='POST'>
<input type='text' value='". $clean ."' name='keywords'/>
<input type='submit' name='submit2' Value='Search'/>
</form>
Header Error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files
(x86)\xampp\htdocs***\index.php:298) in C:\Program Files
(x86)\xampp\htdocs***\pages\search.inc.php on line 35
I'm petty sure that error is due to you trying to output (echo/print) something before trying to redirect in the headers. Redirects header('Location: /anotherpage.php'); after an echo or some printed HTML are probably the cause.
I found the problem in my input for the login submit. Here is what I did.
I change this
<input id="signin_submit" name="submit" value="Sign in" tabindex="6" type="submit">
Too this
<input name="submit" value="Sign in" type="submit">
Apparently the tabindex and id had some kind of issue, not sure why.
Basically what i want to do is when the user allows an application he will automatically signup for my autoresponder list, so i need to pass the user name and email to the form and automatically submit the form.
Here is the first part when i get the user info:
window.fbAsyncInit = function() {
FB.init({appId: 'xxxxxxxxxxxxxxx', status: true, cookie: true, xfbml: true});
};
FB.Event.subscribe('auth.login', function(response) {
if (response.session) {
FB.api({
method: "fql.query",
query: "SELECT name,email FROM user WHERE uid = " + response.session.uid
}
here is the form:
<form method="post" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl" >
<div style="display: none;">
<input type="hidden" name="meta_web_form_id" value="XXXXXXXX" />
<input type="hidden" name="meta_split_id" value="" />
<input type="hidden" name="listname" value="XXXXXX" />
<input type="hidden" name="redirect" value="http://www.aweber.com/thankyou.htm?m=default" id="redirect_e96b2b57089ff7b9fbdbc6ac41355eed" />
<input type="hidden" name="meta_adtracking" value="XXXX" />
<input type="hidden" name="meta_message" value="1" />
<input type="hidden" name="meta_required" value="name,email" />
<input type="hidden" name="meta_tooltip" value="" />
</div>
<div id="af-form-XXXXXXXX" class="af-form"><div id="af-header-XXXXXXXX" class="af-header"><div class="bodyText"><p> </p></div></div>
<div id="af-body-XXXXXXXX" class="af-body af-standards">
<div class="af-element">
<label class="previewLabel" for="awf_field-22176678">Name: </label>
<div class="af-textWrap">
<input id="awf_field-22176678" type="text" name="name" class="text" value="" tabindex="500" />
</div>
<div class="af-clear"></div></div>
<div class="af-element">
<label class="previewLabel" for="awf_field-22176679">Email: </label>
<div class="af-textWrap"><input class="text" id="awf_field-22176679" type="text" name="email" value="" tabindex="501" />
</div><div class="af-clear"></div>
</div>
<div class="af-element buttonContainer">
<input name="submit" class="submit" type="submit" value="Submit" tabindex="502" />
<div class="af-clear"></div>
</div>
</div>
</div>
<div style="display: none;"><img src="http://forms.aweber.com/form/displays.htm?id=HGwsjMxsLOwM" alt="" /></div>
</form>
Now i don't really need all the form code because i don't even want it to show (invisible) and all the forms basically have the same inputs names (name="name", name="email")
so i just wanna enter the list name and pass the user's name and his email to the fields and auto submit it using PHP/JavaScript/Jquery.
There is already scripts which does that and i want to build one my self ;)
EDIT: My friend just gave me this code:
customar_formcode=customar_formcode.replace("{email}", user.email);
customar_formcode=customar_formcode.replace("{name}", user.name);
document.getElementById(\'inneraction\').innerHTML=customar_formcode;
document.getElementById(\'form_id\').submit();
he said the user.name and use.email need to be set from the fql first, honestly i don't understand what i need to do next, do i need to insert the code on the page anyway? do i need to post the form in some special javascript format? what does 'inneraction' means?
Thanks!
Instead of applying this type of patch you may use FB registration........
for detailed information on FB registration see below link
http://developers.facebook.com/docs/plugins/registration/