Jump to content

Bottyz

Members
  • Posts

    107
  • Joined

  • Last visited

Everything posted by Bottyz

  1. <?php include('Connections/lh.php'); //initialize the session if (!isset($_SESSION)) { session_start(); } if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $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; } } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['login_username'])) { $loginUsername=""; $loginUsername=$_POST['login_username']; $password=""; $password=$_POST['login_password']; $errors=""; function validate_email($email) { return preg_match('/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]+\.[A-Za-z0-9_\-\.]+$/', $email) == 0; } if (validate_email($loginUsername) ) { $errors.="ERROR: Please enter a valid email address in the form of [email protected].<br><br>"; } if ($password == '') $errors.="ERROR: Please enter your password.<br><br>"; if ( !$errors ) { $MM_fldUserAuthorization = "activated"; $MM_redirectLoginSuccess = "../LHU/cjproregister.php"; $MM_redirectLoginFailed = "index2.php"; $MM_redirecttoReferrer = true; mysql_select_db($database_lh, $lh); $LoginRS__query=sprintf("SELECT their_username, their_password, activated FROM cjusers WHERE their_username=%s AND their_password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $lh) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'activated'); //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 { $_SESSION['invalid']="true"; header("Location: ". $MM_redirectLoginFailed ); } } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- Design by BottyZ --> <head> <title>Support Area Login</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="keywords" content=""> <meta name="description" content=""> <link href="../LHU/css/mainltblue.css" rel="stylesheet" type="text/css"> <script src="../LHU/jquery.js" type="text/javascript"></script> </head> <!-- ImageReady Slices (Rich Web Visual3.psd) --> <body> <script type="text/javascript"> <!-- $(document).ready(function() { $(".defaultText").focus(function(srcc) { if ($(this).val() == $(this)[0].title) { $(this).removeClass("defaultTextActive"); $(this).val(""); } }); $(".defaultText").blur(function() { if ($(this).val() == "") { $(this).addClass("defaultTextActive"); $(this).val($(this)[0].title); } }); $(".defaultText").blur(); }); //--> </script> <?php if(preg_match('/(?i)msie [1-6]/',$_SERVER['HTTP_USER_AGENT'])) { include_once( '../LHU/ltbluenavie6.php' ); } else { include_once( '../LHU/ltbluenav.php' ); } ?> <div id="main"> <div id="maincontentlogin"> <br> <br> <h1><img src="http://www.bottyz.co.uk/LHU/images/cjlogin.png" alt="CJ Pro Login Area"></h1> <br> <br> <?php $error_color="#61d0fe"; if ($errors) { echo "<div style='padding-left: 50px; margin-left: auto; margin-right: auto; color:"; echo $error_color; echo ";'><br>"; echo $errors; echo "</div><br><br>"; $errors=""; } if ($_SESSION['invalid']="true") { echo "<div style='padding-left: 50px; margin-left: auto; margin-right: auto; color:"; echo $error_color; echo ";'>ERROR: Invalid Username/Password!</div><br><br>"; $_SESSION['invalid']=""; } ?> <form style="margin-left: auto; margin-right: auto;" action="<?php echo $loginFormAction; ?>" method="POST" name="LoginFrom"> <div style="margin-left: auto; margin-right: auto;"> <div style="margin: 0 auto; width: 400px;"> <fieldset> <legend style="color: #61d0fe; font-size: 1.2em;"> Login </legend> <br> <div style="padding-left: 40px;"> <label for="login_username">Email Address: </label> <input class="defaultText" type="text" name="login_username" value="<?php echo htmlentities($loginUsername) ?>" tabindex="1"> <br><br> <label for="login_password">Password: </label> <input class="defaultText" type="password" name="login_password" tabindex="2"> <br><br> <input type="submit" name="Submit" value=" Login " tabindex="3"> <br><br> </div> </fieldset> <br> <div style="margin-left: auto; margin-right: auto; text-align: center;"> <a href="cjproregister.php"><b>Register Now</b></a> | <a href="#"><b>Forgot Password?</b></a></div> <br> </div> </div> </form> <br> <br> <br> </div> </div> <?php include_once( '../LHU/copyright.php' ); ?> </div> </body> </html> That is the full page code. I've contained all login functions within that one page. I've tried teamatomic's method to the best of my ability and it didn't change anything. I can't understand it. The above code i've modified from the original snippet i posted and now displays the error regardless. I've echoed the $_SESSION['invalid'] which is for some reason always true. I'm testing in FF, SAFARI, GC, IE and O. All showing the same. FF has Aadvark and HTML tidy installed.
  2. Hi thanks for the fast reply, There isn't a $_SESSION['error']. Do you mean insert it somewhere? How can i then clear that variable?
  3. Hi all, having a spot of bother unsetting a single $_SESSION variable on a login page. Basically, i'm trying to return an error if the login was unsuccessful due to either the username or password was wrong. I set the $_SESSION['invalid'] variable to equal an error message variable $msg within the check login details if statement. Then after i've set it i use a header to redirect back to the page again. then i use the following code to print it to the page: $error_color="#61d0fe"; $errors2 = $_SESSION['invalid']; if ($errors2) { echo "<div style='padding-left: 50px; margin-left: auto; margin-right: auto; color:"; echo $error_color; echo ";'><br>"; echo $errors2; echo "</div><br><br>"; $errors2=""; unset($_SESSION['invalid']); } but if i use the above unset($_SESSION['invalid']) line the error message doesn't display at all. It destroys it without it printing on the page. However, if i leave it out the error message doesn't disappear until the whole session is reset by clearing the browser history or closing the page. This has been bugging me for a few hours now. Is there any way round it?? Thanks for your help in advance!
  4. Thanks Jl5501, slightly different issue now EDIT... think it is now something to do with my validate function: function validate_fax($fax) { return preg_match('/^([0-9,+() ]{9,})+$/i', $fax); } Is my syntax correct for allowing only digits, brackets, plus symbol and spaces 9 characters minimum in length?
  5. Hi all, just a quickie. I want to only run a validate fax function if a fax number is entered... but i cant get the validate fax function to run from within the if statement. It runs fine if i set it up without the if user_fax!= '' statement. but i want the fax field optional. if ($user_fax != '') { if (validate_fax($user_fax) ) { $errors.="ERROR: Please enter a valid Fax Number including extension if applicable.<br><br>"; } } what am i doing wrong? thanks
  6. Thanks for your reply Daniel but if i remove the code withing the array_reverse brackets i get an invalid arguement error. I only want to reverse the order of the list as its taken from the file. At the minute it is taking the first entry and putting it last. But i want it to put the first entry in the text file first.
  7. Hi all, How can i unreverse or double-reverse the following script? I want the script to read from a text file but with the ID going up not down. function display(){ global $EXHIBIT_ITEM, $EXHIBIT_LIST, $JAVASCRIPT; $CODE_URL = exhibit_CODE_URL; $view = ''; $items = ''; $itemId = count($this->exhibit) + 1; // ORDER IN REVERSE reset( $this->exhibit ); foreach( array_reverse($this->exhibit) as $n ){ $itemId--; if( $this->isLoggedIn() ){ $editLinks = <<<EOT <A HREF="#" ONCLICK="exhibit_ShowElement('exhibit-edit-$itemId'); exhibit_HideElement('exhibit-view-$itemId'); return false;"><b>Edit</b></A> | <A HREF="$CODE_URL?exhibit_action=delete&id=$itemId" ONCLICK="return confirm('Are you sure you want to delete this exhibition item?')"><b>Delete</b></A> EOT; } else { $editLinks = ''; } $formExhibition = htmlentities( $n['exhibition'] ); $formStartdate = htmlentities( $n['startdate'] ); $formEnddate = htmlentities( $n['enddate'] ); $formVenue = htmlentities( $n['venue'] ); $replaces = array( '{EXHIBITION}' => $n['exhibition'], '{FORM_EXHIBITION}' => $formExhibition, '{STARTDATE}' => $n['startdate'], '{FORM_STARTDATE}' => $formStartdate, '{ENDDATE}' => $n['enddate'], '{FORM_ENDDATE}' => $formEnddate, '{VENUE}' => $n['venue'], '{FORM_VENUE}' => $formVenue, '{ITEM_ID}' => $itemId, '{EDIT_LINKS}' => $editLinks, '{CODE_URL}' => exhibit_CODE_URL ); $itemDisplay = str_replace( array_keys($replaces), array_values($replaces), $EXHIBIT_ITEM ); $items .= $itemDisplay; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.