close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

error message trying set up cookie on form

Thread began 9/12/2009 12:50 pm by roywurgley382617 | Last modified 9/16/2009 8:38 am by Jason Byrnes | 5141 views | 10 replies |

roywurgley382617

error message trying set up cookie on form

Good afternoon,

New user to the wa subscription program

I am trying to add a remember me check box to a login form, (now this login was not made using wa ) my registration and login, logout form have been working fine before this, I followed along with the tutorial in the cookie doc page, but now I receive this error notice

Notice: Undefined index:
C:\wamp\www\login_03\login_now.php on line 122
name="rememberme" type="checkbox" id="rememberme" value="" />

any help would be appricated, thx

Sign in to reply to this post

Jason ByrnesWebAssist

What is the code at line 122 of the login_now.php file, I will need to know what the code is that is generating the error to be able to trouble shoot the problem.

Sign in to reply to this post

roywurgley382617

Thx Jason,
I redid everything , and now I don't have error notice, but it does not seem to work.
I am correct that if I login and click "remember me box", the next time I go to login my info will be in the login form or is it that I will be loged in by just going to site. this is the code from that area you asked about, thx again for helping

<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<p>
<label for="username">Username:</label>
<input name="username" type="text" id="username" size="15" />
</p>
<p>
<label for="pwd">Password:</label>&nbsp;
<input name="pwd" type="password" id="pwd" size="15" />
</p>
<p>
<label for="rememberme">Remember me</label>
<input type="checkbox" name="rememberme" id="rememberme" />
</p>

<p>
<input type="submit" name="doLogin" id="doLogin" value="Login" />
</p>
</form>

Sign in to reply to this post

Jason ByrnesWebAssist

It is not remembering your information because you have not set the initial value for the username and password form elements.

Select the Username for element, in the property inspector, click the lightning bolt next to initial value and select the corresponding cookie.

Repeat for the password form element.

Sign in to reply to this post

roywurgley382617

Thx Jason,
I will give it a go, and report back later,
I was looking through the getting started cookie toolkit, the remember tutorial from the resouce area, and I don't see anything in there as what you have told me do, ok I will go give it a try, thx

Sign in to reply to this post

roywurgley382617

Jason,
I am still having problems with this, I have redone everything over, as per the tutorial, I am not getting any error notices but, now I am not able to login, getting login failed, it worked fine before adding this remember me code, so I must have messed something up. I am including my code, is this the right way to include code ? Thx for your help

<?php require_once('Connections/fradmin.php'); ?>
<?php
if (isset($_POST['pwd'])) { $_POST['pwd'] = sha1($_POST['pwd']); }
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['pwd'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "loginfail.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_fradmin, $fradmin);

$LoginRS__query=sprintf("SELECT username, pwd FROM users WHERE username=%s AND pwd=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $fradmin) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("remember", "".((isset($_POST["username"]))?$_POST["username"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}?>
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("password", "".((isset($_POST["pwd"]))?$_POST["pwd"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}?>
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("remember", "1", time()+(60*60*24*30), "/", "", 0);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nascar Sprint Cup Fantasy Racing League Login</title>

<!--[if lte IE 7]>
<link href="styles/p7_42street_msie.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<link href="styles/2009.css" rel="stylesheet" type="text/css" media="screen" />
<link href="styles/2009print.css" rel="stylesheet" type="text/css" media="print" />
</head>
<body onload="P7_rowLite('liteTb1','rowLite')">
<div id="masthead">
<div id="logodiv">
<img src="images/logo2008.gif" alt="Nascar Sprint Cup Fantasy Racing League" width="770" height="111"/>
</div>
</div>
<div id="wrap_outer">
<div id="wrap_inner">
<div id="nav_wrapper">
<img src="images/logo_sprintcup.jpg" alt="Nascar Sprint Cup Racing" width="90" height="47" />
</div>
<div id="mainbox">
<div id="maincontent">
<h3>Member Login </h3>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<p>
<label for="username">Username:</label>
<input name="username" type="text" id="username" value="<?php echo((isset($_COOKIE["username"]))?$_COOKIE["username"]:"") ?>" size="15" />
</p>
<p>
<label for="pwd">Password:</label>&nbsp;
<input name="pwd" type="password" id="pwd" value="<?php echo((isset($_COOKIE["password"]))?$_COOKIE["password"]:"") ?>" size="15" />
</p>
<p>
<label for="rememberme">Remember me</label>
<input <?php if (!(strcmp(((isset($_COOKIE["remember"]))?$_COOKIE["remember"]:""),1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="rememberme" id="rememberme" />
</p>
<p>
<input type="submit" name="doLogin" id="doLogin" value="Login" />
</p>
</form>

Sign in to reply to this post

Jason ByrnesWebAssist

The code that sets the cookies is after the login code, so it will never have the opportunity to set the cookies, the login wuill redirect before it gets to the cooki code.


Move the cookie code:
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("remember", "".((isset($_POST["username"]))?$_POST["username"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}?>
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("password", "".((isset($_POST["pwd"]))?$_POST["pwd"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}?>
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("remember", "1", time()+(60*60*24*30), "/", "", 0);
}
?>

to line 2 so the cookies can be set before he login proceeds.

Sign in to reply to this post

roywurgley382617

Thx Jason,
yes that works, now with this remember me code is it suppose to remember username and password both, or just the password, that is what it is doing just remembering the password. I guess I am trying to get an auto login, Thx again for your help

Sign in to reply to this post

Jason ByrnesWebAssist

it should be remebering both.


your code to set the username cookie, is setting the remember cookie:
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("remember", "".((isset($_POST["username"]))?$_POST["username"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}?>


change it to:
<?php
if ((((isset($_POST["rememberme"]))?$_POST["rememberme"]:"") != "")) {
setcookie("username", "".((isset($_POST["username"]))?$_POST["username"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}?>

Sign in to reply to this post

roywurgley382617

Thx again Jason,
everything working fine, the support is great, and I am glad I went with wa subscription, now can I post again if i hit other php problems that I am incuring with the extensions?, thx again, Roy

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...