Pulling or Auto Populate A Form Input Field - php

Ok i am trying to find if this is possible, i have a single page that has two login forms. But uses the same username and password. Is it possible whereas once i log into one form my username is pulled from the from that already has my username and the password is pulled from the database?
<form action="home.php" method="post" id="LoginForm" style="color:#FFF">
<input type="hidden" name="SessionID" value="new"></input>
Username:
<input type="text" name="AccountNo" value="" class="input" size="28"></input>
<BR /><BR />
Password:
<input type="password" name="Password" value="" class="input" size="30"></input>
<BR />
<input type="image" src="images/input-img.gif" value="Log On" class="input-img"></input>
<BR /><br />
Register now! Forgotten your password?
</form>

If your question is whether it is possible, then answer is yes it is possible.
After you submit the form, you can use JavaScript to read the username from first form and populate it in the second form. To get password, you can AJAX.

Related

How can I create registration form and how can I get what the users filled in that form in my FB app

I have created one app in facebook (using facebook canvas). It is working properly, but I want to know, how can I put a registration form with some fields???
I have written the code for form,
<form action="../form/fbform.php" method="post">
My Name
<input maxlength="50" name="name" type="text" value="" />
My Email
<input maxlength="50" name="email" type="text" value="" />
I Work for
<input maxlength="50" name="cmpny" type="text" value="" />
My Friend
<input maxlength="50" name="frdname" type="text" value="" />
My Friend's Email
<input maxlength="50" name="frdemail" type="text" value="" />
<input name="try" type="submit" value="Submit" />
</form>
That is the code for my form, but after submission it showing blank page.
In action I have written fbform.php, In that file, I have the written the sql code to insert these form details into my website database. and also I have written redirect url to my app. but it's not working.
How can put the registration form in my app and how can I get those details (what users filled in those fields) in my website database or some excel sheet??
I think you need to see the fbml tags to post your data to your desired web page and try the GET method and use the session object of the facebook to retrieve your details .
<form action="../form/fbform.php" method="POST">
<input type="text" name="test1"></input>
<input type="hidden" name="fb_sig_session_key" value=”<?php $_GET[‘fb_sig_session_key’]”></input>
<input type="hidden" name="user_id" value=”<?php $_GET[‘user_id’]”></input>
<input type="submit" name="Submit"/>
</form>

Remember Original Input if the input is invalid

Hi there!
I have a login form like this:
<form method="post" action="login.php">
Username:
<p><input type="text" name="id" /></p>
Password:
<p><input type="password" name="pass" /></p>
<input type="submit" value="Log In" name="login" />
<input type="reset" value="Reset" />
</form>
and the validation is in login.php aswell, a single file validation).
If the email or password doesn't match the error message appears below the form. If the input is valid, it redirects to homepage.php (header ("location: homepage.php");)
What I want to do is: if the password is wrong, or doesn't match with the username, it displays the form again with the original username input.
Is it by using cookie?
If anyone has any suggestion, please let me know.
Sankyu :)
Try saving the old value inside the session variable ($_SESSION) and displaying it on the value property of the element.

AJAX reCAPTCHA verify

I have the next HTML form:
<form name="register" method="post" action="register.php" >
<fieldset>
<legend>Register</legend>
<input type="hidden" name="regform" value="true" />
<label for="username">Username:</label>
<input type="text" name="username" id="username" />
<br />
<label for="email">Email:</label>
<input type="text" name="email" id="email" />
<br />
<label for="password1">Password:</label>
<input type="password" name="password1" id="password1" />
<br />
<label for="password2">Password:</label>
<input type="password" name="password2" id="password2" />
<br />
<?php
$config = new Config();
$publickey = $config->getCaptchaPublicKey();
echo recaptcha_get_html($publickey);
?>
</fieldset>
<input type="submit" value="Register!" />
What I'd like to do, is that when the user presses the submit button, i send the data from the forms via AJAX and verify them.
But I was wondering how I update the recaptcha? I can verify it in my PHP script, and echo a new one included with the error. But how do I send this
back to the client and let javascript (jQuery) replace the old reCAPTCHA with the new?
Hope someone can help me with this.
Greets,
Luxo
PS: Should I use a javascript encryption to encrypt the passwords before sending to the server?
1) to request the image you must request the recaptcha with the correct headers in AJAX
that is send the headers for requesting an image in your case
2) if validating through AJAX you must encrypt or otherwise any bum can touch the passwords
for that just encrypt with the same encryption you would use to store in your database
ex: if you encrypt with md5 from php
instead encrypt the pwd with md5 using JS and send the hash
If you use jQuery then $('#form-id').serialize(); is what you're looking for. Use the data returned from this function as data to post an Ajax.
If you don't have HTTPS then it is worthless to encrypt password with JavaScript.

How to store html form data in a cookie so it's still there after the form is submitted

I have made this html form, it submits all the information to a MySQL database. Pretty simple stuff.
How do I store the username in a cookie so that once it's entered? I would like to ensure that once the user enters their username once, it pre-populates the username field in the future.
<!-- Message board submissionform -->
<form id="frmMB" name="frmMB" action="insert.php" method="post" enctype="multipart/form-data">
<label class="name"><input name="name" placeholder="Enter your name" type="text" id="name" onFocus="if(this.value=='Enter your name'){this.value=''};" onBlur="if (this.value==''){this.value='Enter your name'};" value="Enter your name" size="80" maxlength="10" ></label>
<br />
<label class="message">
<input name="post" placeholder="Enter a message" type="text" id="post" onFocus="if(this.value==this.defaultValue)this.value='';" onBlur="if(this.value=='')this.value=this.defaultValue;" value="Enter a message" size="80" maxlength="140" data-maxsize="3">
</label>
<br />
<label>
<input name="Submit" class="large button" type="submit" value="submit">
</label>
I think something like this would just do this trick.
setcookie($_POST['name'], $value, time()+3600);
if(isset($_COOKIE['name']) && !empty($_COOKIE['name']))
{
// do some stuff here because the name is set in the cookie.
}
First you need to start a session -> session_start()
Once done so, you have created a public $_SESSION array and can add elements to it. Easiest way to do so is:
<?php
if(isset($_POST['username'])){
sesion_start();
$_SESSION['username'] = $_POST['username'];
}
...
Cheers!

wordpress login issue

i have created a custom popup login box. and use form settings like that
<form action="<?php bloginfo('url'); ?>/wp-login.php?redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']); ?>" method="post" autocomplete="off">
and i use input feilds like that
<input id="login_username" name="user_name" type="text" value="" class="pop-input surfix" /><span id="placeholder_user_login">Username</span>
<input id="login_password" name="user_password" type="password" value="" class="pop-input" /><span id="placeholder_user_pass">Password</span>
<input id="register" type="submit" value="Login" class="popup-login-btn" />
but it redirecting to wp-login.php except it should process the login and redirect to the pages where from user started login.
please guide me how can i fix this.
thank you all
actually the issue was with the name element of the input field.
When i check the wp-login.php page i discover the wordpress changes the name of input fields.
<input id="login_username" name="user_name"
<input id="login_password" name="user_password"
to
<input id="login_username" name="log"
<input id="login_password" name="pass"
So i just simply replace the names and all issues were sorted out.
Thank you all

Categories