PDA

View Full Version : Textfields



ff123
05-28-2008, 10:49 PM
is there any JAVASCRIPT thru the text fields like USERNAME ans Password can be saved is Remember Me is Checked..

Nile
05-28-2008, 11:00 PM
I think that it would be easier to do in PHP considering that not all browsers, and people support javascript.

ff123
05-28-2008, 11:40 PM
hmm tell me how to do it in both ways..

Nile
05-30-2008, 02:33 AM
I could tell you how to do it in PHP.
I can also make an example for you if you please.

ff123
05-30-2008, 02:55 AM
yeah sure please.. go ahead..

Nile
05-30-2008, 03:13 AM
Ok, here it is. I spent around 10 minutes on this simple code(See example below):


<?php
if(isset($_POST['submit'])){
if(!empty($_POST[username]) || !empty($_POST[password])){
if($_POST[jeef8ih]){
setcookie('ee13ee', $_POST[username], 60 * 60 * 24 * 60 + time());
}
if($_POST[opppkld]){
setcookie('aa765d', $_POST[password], 60 * 60 * 24 * 60 + time());
}
} else {
}
header('Location: '.$_SERVER[PHP_SELF]);
}
$textInput[1] = (($_COOKIE[ee13ee] == true) ? '<input type="text" name="username" value="'.$_COOKIE[ee13ee].'" />' : '<input type="text" name="username" />');
$textInput[2] = (($_COOKIE[aa765d] == true) ? '<input type="password" name="password" value="'.$_COOKIE[aa765d].'" />' : '<input type="password" name="password" />');
$form = <<< FORM
<form action="$_SERVER[PHP_SELF]" method="post">
<div style="padding:10px;background:lightyellow;border:1px solid gray;">
<span>Username: $textInput[1]<input type="checkbox" name="jeef8ih" />Remember?</span><br />
<span>Password: $textInput[2]<input type="checkbox" name="opppkld" />Remember?</span><br />
<input type="submit" name="submit" value="Login!" />
<b style="color:red;">Note: This is not a real login, it will just remember your details. It will remember your details for two months.</b>
FORM;
echo $form;
?>

In some of the cookie values you'll see some random stuff, its for the security.
Please note that this is not an actual login script, but just a script to remember login details(can be used with text boxes, and more)
If you need me to explain this I will. :D
Example: http://niler.net/examples/rememberMe.php

ff123
05-30-2008, 03:35 AM
how about saving both with one Required check? and Forget Me Button and can i put my own customised text fields in them?

Nile
05-30-2008, 12:00 PM
Ok, what about this? Example Below.


<?php
if(isset($_POST['submit'])){
if(!empty($_POST[username]) || !empty($_POST[password])){
if($_POST[jeef8ih]){
setcookie('ee13ee', $_POST[username], 60 * 60 * 24 * 60 + time());
setcookie('aa765d', $_POST[password], 60 * 60 * 24 * 60 + time());
}
} else {
}
header('Location: '.$_SERVER[PHP_SELF]);
}
if(isset($_POST['forget'])){
setcookie('ee13ee', "", 60 * 60 * 24 * 60 + time());
setcookie('aa765d', "", 60 * 60 * 24 * 60 + time());
header('Location: '.$_SERVER[PHP_SELF]);
}
$textInput[1] = (($_COOKIE[ee13ee] == true) ? '<input type="text" name="username" value="'.$_COOKIE[ee13ee].'" />' : '<input type="text" name="username" />');
$textInput[2] = (($_COOKIE[aa765d] == true) ? '<input type="password" name="password" value="'.$_COOKIE[aa765d].'" />' : '<input type="password" name="password" />');
$form = <<< FORM
<form action="$_SERVER[PHP_SELF]" method="post">
<div style="padding:10px;background:lightyellow;border:1px solid gray;">
<span>Username: $textInput[1]</span><br />
<span>Password: $textInput[2]</span>
<input type="checkbox" name="jeef8ih" />Remember?<br /><input type="submit" name="submit" value="Login!" /><input type="submit" name="forget" value="Forget Me" />
<b style="color:red;"><br />Note: This is not a real login, it will just remember your details. It will remember your details for two months. You can also overwrite it.</b>
FORM;
echo $form;
?>http://niler.net/examples/rememberMe[2].php (http://niler.net/examples/rememberMe%5B2%5D.php)
If you gimme your login code I can plug this one in for you.

ff123
05-30-2008, 01:05 PM
here is my HTML code i don't think so it can be fixed in Php..

<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="259" height="5">
<tr>
<td width="259" bgcolor="#EBF3F9" height="170">
<form method="POST" action="go.php" name="login">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="240">
<tr>
<td width="100%"><b>
<font face="Arial" size="2" color="#3D3643"><br>
Username</font></b></td>
</tr>
<tr>
<td width="100%">
<input type="text" name="username" size="22" style="font-size: 20; padding-top: 2; padding-bottom: 5"></td>
</tr>
<tr>
<td width="100%">&nbsp;</td>
</tr>
<tr>
<td width="100%"><b>
<font face="Arial" size="2" color="#3D3643">Password</font></b></td>
</tr>
<tr>
<td width="100%">
<input type="password" name="password" size="22" style="font-size: 20; padding-top: 2; padding-bottom: 5"></td>
</tr>
<tr>
<td width="100%">&nbsp;</td>
</tr>
<tr>
<td width="100%">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="230">
<tr>
<td width="50%">
<p align="left">
<label><input type="checkbox" name="C1" value="ON"><font size="1" face="Verdana">Remember
Me<br>
<a href="forget">Forget Me</a></font></label></td>
<td width="50%">
<p align="right">
<input type="submit" value="Log In" style="font-size: 12pt; color: #000000; border: 1px solid #006699; padding-top: 2; padding-bottom: 5; background-color: #C1DAEC"></td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</div>
<input type="hidden" name="action" value="dologin">
</form>
<br></td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>

Nile
05-30-2008, 09:25 PM
Ok, go.php:


<?php
if(isset($_POST['submit'])){
if(!empty($_POST[username]) || !empty($_POST[password])){
if($_POST[jeef8ih]){
setcookie('ee13ee', $_POST[username], 60 * 60 * 24 * 60 + time());
setcookie('aa765d', $_POST[password], 60 * 60 * 24 * 60 + time());
}
} else {
}
}
if(isset($_POST['forget'])){
setcookie('ee13ee', "", 60 * 60 * 24 * 60 + time());
setcookie('aa765d', "", 60 * 60 * 24 * 60 + time());
//your code goes here
}

On the page you shows me:


<?php
$textInput[1] = (($_COOKIE[ee13ee] == true) ? '<input type="text" name="username" size="22" style="font-size: 20; padding-top: 2; padding-bottom: 5" value="'.$_COOKIE[ee13ee].'">' : '<input type="text" name="username" size="22" style="font-size: 20; padding-top: 2; padding-bottom: 5" />');
$textInput[2] = (($_COOKIE[aa765d] == true) ? '<input type="password" name="password" size="22" style="font-size: 20; padding-top: 2; padding-bottom: 5" value="'.$_COOKIE[aa765d].'">' : '<input type="password" name="password" size="22" style="font-size: 20; padding-top: 2; padding-bottom: 5">');
$form = <<< FORM
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="259" height="5">
<tr>
<td width="259" bgcolor="#EBF3F9" height="170">
<form method="POST" action="go.php" name="login">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="240">
<tr>
<td width="100%"><b>
<font face="Arial" size="2" color="#3D3643"><br>
Username</font></b></td>
</tr>
<tr>
<td width="100%">
$textInput[1]</td>
</tr>
<tr>
<td width="100%">&nbsp;</td>
</tr>
<tr>
<td width="100%"><b>
<font face="Arial" size="2" color="#3D3643">Password</font></b></td>
</tr>
<tr>
<td width="100%">
$textInput[2]</td>
</tr>
<tr>
<td width="100%">&nbsp;</td>
</tr>
<tr>
<td width="100%">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="230">
<tr>
<td width="50%">
<p align="left">
<label><input type="checkbox" name="jeef8ih" /><font size="1" face="Verdana">Remember Me?</font><br /><input type="submit" name="forget" value="Forget Me" />
<a href="forget">Forget Me</a></font></label></td>
<td width="50%">
<p align="right">
<input type="submit" name="submit" value="Login!" /></td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</div>
<input type="hidden" name="action" value="dologin">
</form>
<br></td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
FORM;
echo $form;
?>

See if that works. Although I think it will, tell me.

ff123
05-31-2008, 03:48 AM
here is the output im having

http://img75.imageshack.us/img75/3462/66422839iy5.jpg

Nile
06-01-2008, 02:08 AM
Is the format a PHP page? Or an HTML?
I got that output that you got when I had an HTML formatted page.

ff123
06-01-2008, 10:56 AM
its working ok in Php formatted page.. It's not saving in fields.. But why I should put code in Go.php too? can't it be just in login page..? Are cookies safe..?

Nile
06-01-2008, 12:30 PM
You should put it in go.php because thats where the form is submitting to.

ff123
06-01-2008, 12:40 PM
i added that in go.php but its not saving the content in text fields..

Nile
06-01-2008, 12:41 PM
Lemme see your go.php.

ff123
06-01-2008, 02:40 PM
go.php is secured page.. why can't we just save the info by using codes in login page like you used earlier.

Nile
06-01-2008, 02:46 PM
Because then we'd have to use hidden inputs because PHP can't send post data by itself, and that'd just make it harder for me. Can you send it to me in a PM by chance?