PHP - Using Uppercase Pw Check.
Problem - application produces MD5 PWs which are uppercase, code checks lowercase.
Question- How to use uppercase check? Code: [Select] function checkPwd($x,$y) { //Checks if strings are empty if(empty($x) || empty($y) ) { //Strings were empty return false; } else if(strlen($x) < 4 || strlen($y) < 4) { //String length too short return false; } else if(strcmp($x,$y) != 0) { //Strings do not match return false; } else { //Password Determined valid return true; } } Question 2: Do I have to change it anywhere else, like PW generation? Code: [Select] function GenPwd($length = 7) { $password = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyz"; //no vowels $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } function GenKey($length = 7) { $password = ""; $possible = "0123456789abcdefghijkmnopqrstuvwxyz"; $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } Thank you for reading Similar TutorialsHi Friends, I am Anes I want to ensure all surnames are uppercase in php I use $surname = ucfirst(strtolower($dataField)); How do I ensure that any names such as O'Brien, don't result in O'brien thanks Hello: I have this little bit of code to pull all the towns and zip codes from a mySQL database: Code: [Select] <?php $result = mysql_query("SELECT zip_id,city,abbr_state,full_state,zip FROM zip_codes WHERE abbr_state = '" . mysql_real_escape_string ( $_GET['abbr_state'] ) . "' ORDER BY `city` ASC"); while($row = mysql_fetch_array($result)) { echo "<a href=\"Stores.php?zip_id=".$row['zip_id']."\" title=\"My Products ". $row['city']. ", ". $row['abbr_state']." ". $row['zip']." | My Items ". $row['city']. ", ". $row['abbr_state']." ". $row['zip']."\">". $row['city']. ", ". $row['abbr_state']." ". $row['zip']."</a>"; echo "<div style=\"clear: both; margin-bottom: 15px;\"></div>"; } ?> Works fine (unless some can offer a way to "improve" the code). However, all of the City Names ($row['city']) were put into the database as ALL CAPITALS, which is a bit harder on the eyes to read. Is there a "PHP way" - working with the code I posted - that will transform the ALL CAPITALS to a more readable Capitalize (in other words, Capitalize just the first letter of each town). I know that CSS offers "text-transform" and if that is a solution I'm fine with that. I just need it to display that way, not re-write it in the database. Ideas? Solution? Thanks! Our professor in PHP Programming is very choosy that he requires us to verify if the user enter the UPPERCASE format of the user name registered the program will show an invalid user. What he's trying to say is the user must enter a 100% identical to the username he registered. If the username registered is LOWERCASE he must enter a LOWERCASE username if the username registered is UPPERCASE he must enter an UPPERCASE username to LOGIN. Hi I have this script that saves data to a file, I was wondering how I can make the script write the title of the files in uppercase letters? I am new to coding mind I think is the relevent code: Code: [Select] foreach(array('daily','weekly','monthly') as $value) { $fp = fopen(DIR.$value.'_'.strtolower(str_replace('/', '', $data[$ccyValue][0])).'.csv', 'w'); if($fp) { $raw_data = array(${$value.'Pivot'}, ${$value.'_s1'}, ${$value.'_s2'}, ${$value.'_s3'}, ${$value.'_r1'}, ${$value.'_r2'}, ${$value.'_r3'}); $write_data = "Pivot, S1, S2, S3, R1, R2, R3\n"; $write_data .= implode(',', $raw_data); fwrite($fp,$write_data); fclose($fp); } else { die('Please make sure result folder is present or writable!'); } } } Thanks Antony ok so i can get this to work so i want to check if there is a video on inside my db if there is no video and nothing happens but if there is i want it to echo video Code: [Select] <?php if($video == ""){ }else{ echo "VIDEO"; } ?> Hello their, I'm wanting to use PHP to check to see if a username and password match a remote RDP server. The reason I ask is because I want to verify that the information the user is giving is correct. I'm looking though LDAP but I have no idea what I'm looking for. To recap, I would like to login to a RDP server and return a result based on if it completed. Thank-you for reading Paul P.S Sorry for the bad English, I seemed to forgot how to spell some words and have had to replace them with longer sentences Suppose i have a table with around 10 entries in which one column contains the id and the second column contains a checkbox... If a checkbox a selected and the button (below the table) is pressed then i want to delete the columns corresponding the checked checkboxes.... I am not getting how sgould i pass the get variable on the link of the button??? -Pranshu Agrawal pranshu.a.11@gmail.com Hello, I have created a little voting script for my site. The insertion code into the MySQL databse when they vote is very simple: $ipaddress = addslashes($_POST['ipaddress']); $theid = addslashes($_POST['theid']); $gamert = addslashes($_POST['gamert']); $serveron = addslashes($_POST['serveron']); $db = mysql_connect("localhost", "username", "password"); mysql_select_db("thedb",$db); mysql_query ("INSERT INTO voting (theid,ipaddress,gamert,serveron2) VALUES ('$theid','$ipaddress','$gamert','$serveron') "); Obviously I only want them to be able to vote once. What is the best way to do a check of the IPs already in the database and check against theirs before submitting? Thanks. I am unable to execute mysql_num_rows properly in this program. Code: [Select] <?php $link=mysql_connect("localhost","root",""); $db = mysql_select_db("myDB",$link); $result = mysql_query("SELECT * FROM jobs WHERE jobType=abc"); $num = mysql_num_rows($result); echo "Found $num records"; ?> error is mysql_num_rows() expects parameter 1 to be resource does anyone have code for checking to make sure an email address is typed in correct Hi, I am trying to see if the domain name in the string is in an array. eg; Code: [Select] mystring='http://google.com/somethingelse'; myarray[]='google.com'; myarray[]='anotherdomain.com'; in this case return TRUE Code: [Select] mystring='http://phpfreaks.com/adir'; myarray[]='google.com'; myarray[]='anotherdomain.com'; in this case return FALSE How would I do this? Thanks, -mme This is suppose to check a table to see if it has a value in it. I get this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /homepages/6/d365637117/htdocs/EE Live/Active/Inc/session.php on line 33 This is the code if($checkProfile) { $result = mysql_query("SELECT prof_pic FROM members_profile WHERE id = '".$_SESSION['EEID']."'"); $mem_num_rows = mysql_num_rows($result); if($mem_num_rows =1) { } Code: [Select] public function getBonusChildren($userID) { if($userID != NULL) { $sql = 'SELECT COUNT(*) AS count, userID FROM jos_backoffice_users WHERE parentID= ' . $userID . ';'; $stmt = conn::getInstance()->prepare($sql); $stmt->execute(); $obj = $stmt->fetchAll(PDO::FETCH_ASSOC); if(is_object($obj)) { $obj->count += $this->getBonusChildren($obj->userID); } } return $obj->count; } I get no error. It just always return null. How can I get this done? What is the best way to check for a Date in a Form? I see there is a CheckDate() function, but how does that know what format the Date is in? Should I use a Regular Expression? My Form Field is just a Text Box... Thanks, Debbie Hey, I'm trying to check if a username is unique, but for some reason none of the methods that I've looked up seem to work. I'm aiming for the code to check if a username is unique, and if get the user to input the name again. $get = "SELECT `i` FROM `m` WHERE `i`=\"$r\""; $checkResults = mysql_query($getRandomness); while(mysql_num_row($checkResults) > 0) { //some code... //check again $get = "SELECT `i` FROM `m` WHERE `i`=$r"; $checkResults = mysql_query($get); } The error comes from the while line, but it comes up during the first check because the record is empty. This is the error: "Fatal error: Call to undefined function mysql_num_row()" Hi , I have a login page that i acces via www.mydomain.com/logib.php?last_visited_page.php however the passed in variable last_visited_page.com is not always set . once the login script has run , when the variable it is not set i would want jump to myaccount.php otherwise jump to last_visited_page.php How do i check for no variable beinf present and therefore jump to myaccount.php Many Thanks Fraser I have the variables $cap and $url If the $cap contains any of the strings ".jpg,.JPG,.gif,GIF" I have to concatenate $url.$cap I am new to PHP. I developed this class, I wonder if there's anything wrong or that I can improve. I could not test it because I'm in school. Thanks in advance. Code: [Select] <? class user { var $userID, $schoolID, $userName, $userPass, $dbHost, $dbUser, $dbName, $dbPass, $dbUserTable; $dbSchoolTable; function dbInfo() { $this->dbHost = 'localhost'; $this->dbUser = ''; $this->dbName = ''; $this->dbPass = ''; $this->dbUserTable = ''; $this->dbSchoolTable = ''; } function registerUser($userName, $userPass) { $dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass); if(!$dbLink) die("Could not connect to database: " . mysql_error()); mysql_select_db($this->dbName); $query = "INSERT INTO $this->dbUserTable VALUES (NULL, \"$userName\", \"$userPass\")"; $result = mysql_query($query); if(!$result) { echo "Fail."; } else { $this->userID = mysql_insert_id(); } mysql_close($dbLink); $this->userName = $userName; $this->userPass = $userPass; } function registerSchool($schoolName) { $dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass); if(!$dbLink) die("Could not connect to database: " . mysql_error()); mysql_select_db($this->dbName); $query = "INSERT INTO $this->dbSchoolTable VALUES (NULL, \"$schoolName\")"; $result = mysql_query($query); if(!$result) { echo "Fail."; } else { $this->schoolID = mysql_insert_id(); } mysql_close($dbLink); $this->schoolName = $schoolName; } function userLogin() { $dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass); if(!$dbLink) die("Could not connect to database: " . mysql_error()); mysql_select_db($this->dbName); $query = "SELECT * FROM $this->dbUserTable WHERE userName = \"$this->userName\" AND userPass = \"$this->userPass\" LIMIT 1"; $result = mysql_query($query); if(!$result) { echo "Fail."; } else { while($row = mysql_fetch_array($result)) { session_start(); $_SESSION['userID'] = $row['userID']; session_write_close(); } } mysql_close($dbLink); } function changePass($newPass) { $dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass); if(!$dbLink) die("Could not connect to database: " . mysql_error()); mysql_select_db($this->dbName); $query = "SELECT * FROM $this->dbUserTable WHERE userName = \"$this->userName\" LIMIT 1"; $result = mysql_query($query); if(!$result) { echo "Fail."; } else { $query = "UPDATE $this->dbUserTable SET userPass = \"$newPass\" WHERE userName = \"$this->userName\""; $result = mysql_query($query); if(!$result) { echo "Fail"; } else { $this->userPass = $newPass; } } mysql_close($dbLink); } } ?> Hi, I'd like to know what the most efficient code is for checking the first 2 digits of a string. eg a strings first 2 digits must equal '07' thanks, |