Jump to content

Obadiah

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Obadiah's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am using PHP Version 5.3.1 and MYSQL 5.1.41 and I have my select statement here however i was not sure with the php that im using to filter the results if I should have or could have posted it here or in the PHP section, as part of my question pertains to it as well...if i am posting in the wrong place please let me know and i will move it. ok this is killin me its not working and when it works it works backwards...whats happening is when I use $DArea anywhere in the Query it doesnt work, If I choose a different Area than one in the database It executes the Else Statement(not supposed to do that) and it post data from the same Month, Year and Area to the database...once again what im trying to do is not allow any information from an Area "$DArea" in the database unless the Month or the Year is different. In other words If I fill out information from area "Gym" on November("DMonth") of 2010("DYear") the next time i will be allowed to enter data on it is next month. And if you were wondering Dmonth and DYear are variables tied to the time() function abd it does pass the correct month and time to the database. $DArea = $areaReported; $query = mysql_query("SELECT * FROM $table_name WHERE Month ='$DMonth' AND Year= '$DYear' AND Area = '$DArea'") or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $dbMonth = $row['Month']; $dbYear = $row['Year']; $dbArea = $row['Area']; } if ($DMonth==$dbMonth&&$DYear==$dbYear&&$DArea==$dbArea) { mysql_query("INSERT INTO $table_name (user_id, Date, Month, Year, Area, percent1, stat1) values ('{$user_id}', '{$realdate}', '{$DMonth}', '{$DYear}', '{$DArea}', '{$percent1}', '{$stat1}')"); // defining the output include("output.inc"); if ($total == "1"){ $output = $output1; } else if ($total == "2"){ $output = $output2; } else if ($total == "3"){ $output = $output3; } else if ($total == "4"){ $output = $output4; } else if ($total == "5"){ $output = $output5; } else if ($total == "6"){ $output = $output6; } else if ($total == "7"){ $output = $output7; } else if ($total == "8"){ $output = $output8; } else if ($total == "9"){ $output = $output9; } else if ($total == "10"){ $output = $output10; } } else echo "<p style=\"color:red;\">A Report for this $areaReported has already been submitted for this Month</p>"; } I have also tried the statement this way. ("SELECT 'Month', 'Year', 'Area' FROM 'data' WHERE 'Month' ='$DMonth' AND 'Year'='$DYear' AND 'Area' = '$DArea'") If it stops any info from hitting the database it stops it all and when the error message I want to appear when someone tries to enter a duplicate record from a specific area for the same month, it does not show unless its a month that does not exist in the database and to get that to even show up I have to take the Area Clause out of the Select statement. I am out of ideas on this one. Can anyone tell me if im even going in the right direction here? Please help
  2. if I were you Id use Xampp...skip the headache bro! its a all-in-one pakage deal that you can use on whatever you want...do a google search for xampp...i think you will like it!
  3. I am using PHP Version 5.3.1 and MYSQL 5.1.41 and I have my select statement here however i was not sure with the php that im using to filter the results if I should have or could have posted it here or in the PHP section, as part of my question pertains to it as well...if i am posting in the wrong place please let me know and i will move it. ok this is killin me its not working and when it works it works backwards...whats happening is when I use $DArea anywhere in the Query it doesnt work, If I choose a different Area than one in the database It executes the Else Statement(not supposed to do that) and it post data from the same Month, Year and Area to the database...once again what im trying to do is not allow any information from an Area "$DArea" in the database unless the Month or the Year is different. In other words If I fill out information from area "Gym" on November("DMonth") of 2010("DYear") the next time i will be allowed to enter data on it is next month. And if you were wondering Dmonth and DYear are variables tied to the time() function abd it does pass the correct month and time to the database. $DArea = $areaReported; $query = mysql_query("SELECT * FROM $table_name WHERE Month ='$DMonth' AND Year= '$DYear' AND Area = '$DArea'") or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $dbMonth = $row['Month']; $dbYear = $row['Year']; $dbArea = $row['Area']; } if ($DMonth==$dbMonth&&$DYear==$dbYear&&$DArea==$dbArea) { mysql_query("INSERT INTO $table_name (user_id, Date, Month, Year, Area, percent1, stat1) values ('{$user_id}', '{$realdate}', '{$DMonth}', '{$DYear}', '{$DArea}', '{$percent1}', '{$stat1}')"); // defining the output include("output.inc"); if ($total == "1"){ $output = $output1; } else if ($total == "2"){ $output = $output2; } else if ($total == "3"){ $output = $output3; } else if ($total == "4"){ $output = $output4; } else if ($total == "5"){ $output = $output5; } else if ($total == "6"){ $output = $output6; } else if ($total == "7"){ $output = $output7; } else if ($total == "8"){ $output = $output8; } else if ($total == "9"){ $output = $output9; } else if ($total == "10"){ $output = $output10; } } else echo "<p style=\"color:red;\">A Report for this $areaReported has already been submitted for this Month</p>"; } I have also tried the statement this way. ("SELECT 'Month', 'Year', 'Area' FROM 'data' WHERE 'Month' ='$DMonth' AND 'Year'='$DYear' AND 'Area' = '$DArea'") If it stops any info from hitting the database it stops it all and when the error message I want to appear when someone tries to enter a duplicate record from a specific area for the same month, it does not show unless its a month that does not exist in the database and to get that to even show up I have to take the Area Clause out of the Select statement. I am out of ideas on this one. Can anyone tell me if im even going in the right direction here? Please help
  4. Hi guys, I need assistance with some code for my login script. I had to redo it because of several changes made to my database. for some reason when I run my login script it doesnot pick up that the password is there(or that it is correct) since my error displays when i submit the user and password. many thanks for your help in advance! the username field in sql is user_id the password field in sql is user_pass here is the array $fields_1 = array("fusername" => "User Name", "fpassword" => "Password" ); $length_1 = array("fusername" => "10", "fpassword" => "10" ); here is my login script <?php /* Program: Login.php */ session_start(); include("functions_main.inc"); $table_name = "users"; $next_program = "home.php"; switch (@$_POST['Button']) { case "Login": $cxn = Connect_to_db("Vars.inc"); $sql = "SELECT user_id FROM $table_name WHERE user_id='$_POST[fusername]'"; $result = mysqli_query($cxn,$sql) or die("Couldn't execute query 1"); $num = mysqli_num_rows($result); if($num == 1) { $sql = "SELECT user_id FROM $table_name WHERE user_id='".mysqli_real_escape_string($cxn,$_POST['fusername'])."' AND user_pass=md5('$_POST[fpassword]')"; $result2 = mysqli_query($cxn,$sql) or die("Couldn't execute query 2."); $row = mysqli_fetch_assoc($result2); if($row) { $_SESSION['auth']="yes"; $_SESSION['logname'] = mysqli_real_escape_string($cxn,$_POST['fusername']); header("Location: $next_program"); } else { /*this is the message that keeps displaying even though the password is correct*/ $message_1="The Login Name, '$_POST[fusername]' exists, but you have not entered the correct password! Please try again.<br>"; extract($_POST); include("fields_login.inc"); include("double_form.inc"); } } elseif ($num == 0) // login name not found { $message_1 = "The User Name you entered does not exist! Please try again.<br>"; include("fields_login.inc"); include("double_form.inc"); } break; case "Register": /* Check for blanks */ foreach($_POST as $field => $value) { if ($field != "fax") { if ($value == "") { $blanks[] = $field; } } } if(isset($blanks)) { $message_2 = "The following fields are blank. Please enter the required information: "; foreach($blanks as $value) { $message_2 .="$value, "; } extract($_POST); include("fields_login.inc"); include("double_form.inc"); exit(); } /* validate data */ foreach($_POST as $field => $value) { if(!empty($value)) { if(eregi("name",$field) and !eregi("user",$field) and !eregi("log",$field)) { if (!ereg("^[A-Za-z' -]{1,50}$",$value)) { $errors[] = "$value is not a valid name."; } } if(eregi("street",$field)or eregi("addr",$field) or eregi("city",$field)) { if(!ereg("^[A-Za-z0-9.,' -]{1,50}$",$value)) { $errors[] = "$value is not a valid address or city."; } } if(eregi("state",$field)) { if(!ereg("[A-Za-z]",$value)) { $errors[] = "$value is not a valid state."; } } if(eregi("email",$field)) { if(!ereg("^.+@.+\\..+$",$value)) { $errors[] = "$value is not a valid email address."; } } if(eregi("zip",$field)) { if(!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$value)) { $errors[] = "$value is not a valid zipcode."; } } if(eregi("phone",$field) or eregi("fax",$field)) { if(!ereg("^[0-9)(xX -]{7,20}$",$value)) { $errors[] = "$value is not a valid phone number. "; } } } } foreach($_POST as $field => $value) { if($field != "Button") { if($field == "password") { $password = strip_tags(trim($value)); } else { $fields[]=$field; $value = strip_tags(trim($value)); $values[] = addslashes($value); $$field = $value; } } } if(@is_array($errors)) { $message_2 = ""; foreach($errors as $value) { $message_2 .= $value." Please try again<br />"; } include("fields_login.inc"); include("double_form.inc"); exit(); } $user_name = $_POST['user_name']; /* check to see if user name already exists */ $cxn = Connect_to_db("Vars.inc"); $sql = "SELECT user_id FROM $table_name WHERE user_id='$user_name'"; $result = mysqli_query($cxn,$sql) or die("Couldn't execute query."); $num = mysqli_num_rows($result); if ($num > 0) { $message_2 = "$user_name already used. Select another User Name."; include("fields_login.inc"); include("double_form.inc"); exit(); } else { $today = date("Y-m-d"); $fields_str = implode(",",$fields); $values_str = implode('","',$values); $fields_str .=",create_date"; $values_str .='"'.",".'"'.$today; $fields_str .=",password"; $values_str .= '"'.","."md5"."('".$password."')"; $sql = "INSERT INTO $table_name "; $sql .= "(".$fields_str.")"; $sql .= " VALUES "; $sql .= "(".'"'.$values_str.")"; mysqli_query($cxn,$sql) or die(mysqli_error($cxn)); $_SESSION['auth']="yes"; $_SESSION['logname'] = $user_name; /* send email to new Customer */ $emess = "You have successfully registered. "; $emess .= "Your new user name and password are: "; $emess .= "\n\n\t$user_name\n\t"; $emess .= "password\n\n"; $emess .= "We appreciate your interest. \n\n"; $emess .= "If you have any questions or problems,"; $emess .= " email service@ourstore.com"; $subj = "Your new customer registration"; #$mailsend=mail("$email","$subj","$emess"); header("Location: $next_program?user='.$user_name"); } break; default: include("fields_login.inc"); include("double_form.inc"); } ?>
  5. what im attempting to do is get php to spill rthe contents of the files in the last folder...right now it will only search the folders preceding the last and when it gets to the last one it opens it but doesent search the files inside....can anyone help me?!? <?php $indent = str_repeat("\t", 5); $dirname = "resids/{$_SESSION['logname']}/{$_POST['xyz']}"; $filename= "*.pdf"; if (!is_dir($dirname)) { $dirname="{$_POST['xyz']}"; echo $indent . '<option>Invalid directory specified.</option></select><br>'; echo "<select name=\"abc\">"; $dh=opendir($ob) or die("couldn't open directory"); while(!(($filea = readdir($dh)) === false)) {         echo"<option>$filea</option>"; } echo "</select>"; } else {   $dh = opendir($dirname) or die("couldn't open directory");   while(($file = readdir($dh)) !== false)   {     if ($file != '.' and $file != '..')     {       echo $indent . '<option' . ((isset($_POST['xyz']) && $_POST['xyz'] == $file) ? ' selected="selected"' : '') . '>' . $file . '</option>' . PHP_EOL;     }   } } ?>
×
×
  • 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.