patelp7 Posted March 4, 2007 Share Posted March 4, 2007 im doing a project for college...and keep getting this error. Please help! Notice: Undefined variable: errorstring in h:\Project\HTDOCS\new patient database\AddUser1.php on line 60 if (mysql_errno()<>0) { $error =1; $errorstring = mysql_error() . "\n"; } }else{ $error=1; } if(($Userlen<6) || ($Userlen>15)){ $errorstring.="<BR>Your username was $Userlen characters long it must be between 6 and 15 characters long.<BR>"; } if (($Passlen<5) || ($Passlen>15)){ $errorstring.="<BR>your password was $Passlen characters long it must be between 5 and 15 characters long<BR>"; } } if ($error<>0){ DisplayAddForm($errorstring); }else{ $Username=$_session['Username']; //$Userlevel= $_session['Userlevel']; Displaymenu($Username, "User successfully added"); } }else{ DisplayAddForm($errorstring); } Quote Link to comment Share on other sites More sharing options...
simcoweb Posted March 4, 2007 Share Posted March 4, 2007 We need to know what line 60 contains. You should probably post the whole script so we can help. Quote Link to comment Share on other sites More sharing options...
patelp7 Posted March 4, 2007 Author Share Posted March 4, 2007 <? session_start(); require("db.php.inc"); require ("addfunc.inc"); if (isset($_POST['SUBMIT']) ){ extract($_POST); $error=1; //check to see variables are set if ( (isset($Username)) && (isset($Password)) ) { //set error flag to 0 $error=0; //Remove leading and trailing white spaces in input $Username=trim($Username); $Password=trim($Password); //check to see if username and password contain sufficient characters $Userlen = strlen($Username); $Passlen = strlen($Password); if ( (($Userlen>5) && ($Userlen<20))&&(($Passlen>4)&&($Passlen<15)) ){ $Encryptedpassword = crypt($Password, "ND"); $query = "insert into adminmember (Username, Password, First_Name, Last_Name, EmailAdd, User_Level) Values ('$Username', '$Encryptedpassword', '$First_Name', '$Last_Name', '$EmailAdd', '$value')"; $result=mysql_query($query); if (mysql_errno()<>0) { $error =1; $errorstring = mysql_error() . "\n"; } }else{ $error=1; } if(($Userlen<6) || ($Userlen>15)){ $errorstring.="<BR>Your username was $Userlen characters long it must be between 6 and 15 characters long.<BR>"; } if (($Passlen<5) || ($Passlen>15)){ $errorstring.="<BR>your password was $Passlen characters long it must be between 5 and 15 characters long<BR>"; } } if ($error<>0){ DisplayAddForm($errorstring); }else{ $Username=$_session['Username']; //$Userlevel= $_session['Userlevel']; Displaymenu($Username, "User successfully added"); } }else{ DisplayAddForm($errorstring); } ?> the BOLD code Quote Link to comment Share on other sites More sharing options...
simcoweb Posted March 4, 2007 Share Posted March 4, 2007 Do you have the $errorstring defined in this function? DisplayAddForm($errorstring); Quote Link to comment Share on other sites More sharing options...
patelp7 Posted March 4, 2007 Author Share Posted March 4, 2007 <? function DisplayAddForm ($errorstring) { print (' <html> <head>Registration Details</head> <body> <H3>Add Admin</H3> <P>Please enter your username and password</p>'); echo $errorstring; print(' <form action="AddUser1.php" method=post> <br> <b>Username :</b><input type=text name="Username"><br><br> <b>Password :</b><input type=password name ="Password"><BR><br> <b>First Name :</b><input type=text name ="First_Name"><BR><br> <b>Last Name :</b><input type=text name ="Last_Name"><BR><br> <b>Email Address :</b><input type=text name ="EmailAdd"><BR><br> <b>Administrator </b><input type =radio name = userlevel value=1> <BR><BR> <Input type =SUBMIT name ="SUBMIT" value="SUBMIT"> <Input type = Reset> </form> </body> </html> '); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.