Jump to content

dk4210

Members
  • Posts

    154
  • Joined

  • Last visited

Posts posted by dk4210

  1. Ok what would you use instead of is_numberic?

     

    What if I wanted to just strip the comma?

     

    When I added this code

     

    function check_Price($price,$member_id,$description,$ip){
     $price = str_replace(',', '', $price);
    if (isset($price) && (!is_numeric($price)))
    {
          Echo "No";
    }
    
    }
    
    

     

    If I enter in something like 24,555

     

    I get just 24 in the database..It removes the comma but everything after words.

     

     

  2. Hello Guys,

     

    I check the price field on the server side and I am trying to figure out how to allow a comma in the price field

     

    example 2,300

     

    Here is the code I use to check the price.

    function check_Price($price,$member_id,$description,$ip){
    if (isset($price) && (!is_numeric($price)))
    {
          do something here
    }
    
    }
    

    Thanks in Advance!

    Dan

     

  3. They don't have the exact information.. Think of an application with 6 forms. All of them have a member id ect but different options..

     

    Combining all the together in one table would result in a mile long table, therefore we separated the forms into separate tables.

     

     

  4. Hi Fenway,

     

    I am with Labrat on this project and the reason there is two different tables is because we are adding data to both tables...

     

    Form A submits to Table 1

    Form B submits to Table 2

     

    We want to count table contents of both..

  5. Yea I a little above basic... I did echo out the vars to see if what I was expected is what it echo'd out and it was..

    Thanks for the help..

     

    It works with radio buttons but not a drop down..I'm Baffled.. I will just use radio button instead..

  6. I tried that already.. About every combo you can think of.. i finally just changes it from a drop down to a radio button and it works fine..I don't understand the difference..

     

    
    function check_Race ($race,$display_name,$member_id,$description,$ip) {
    
     if (isset($race) && $race != 'White' && $race != 'Black'){	
         	     	
    	 $t_error="19";
    	$member_id = $member_id;
    	notify_Admin($t_error,$member_id,$ip);				
    	logOut ($t_error);
    	exit;
    
    }
    
    
    }

     

    Radio button code

     

    <div class="hcenter"><div class="box3">Ethnicity</div></div>
    	<div class="box2"><input type="radio" name="race" value="White" />White<br />
            <input type="radio" name="race" value="Black" />Black<br /></div>
    
    

     

     

  7. This grabs all the post vars

     

    $_POST = array_map('strip_tags', $_POST);
        $_POST = preg_replace( "^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$^", " ", $_POST );
        $_POST = array_map('mysql_real_escape_string', $_POST);
       // array_walk_recursive($_POST, 'filter');
        extract($_POST,EXTR_SKIP);
    

     

    This is the function call

    check_Race ($race,$display_name,$member_id,$description,$ip); // Check Race
    

     

    I also echo'd out the $race var before the call and inside the function it's self and the var has the expected value.

  8. This is my html from the form

     

    <select size="1" name="race">
    	<option value="0"></option>
    			<option value="White">White / Caucasian </option>
    			<option value="Black">Black / African American </option>
    			<option value="Hispanic">Hispanic </option>
    			<option value="Asian">Asian / Pacific Islander </option>
    
    			<option value="Arabic">Arabic / Middle Eastern</option>
    			<option value="Native_american">Native American Indian</option>
    			<option value="Other">Other</option>
    
    		  </select></div>
    

  9. This is blowing my mind. I have this function and all I want it to do is check to make sure that the var $race is set and = '0'. The default value from the form is '0'. I also want it to check the value of race and if it is anything but the two listed , submit error. Yes I've tried to replace the || with &&.. Nothing works(Meaning that it will error when its not suppose to or it wont error when its suppose to).. Any ideas?

     

     

     

    function check_Race ($race,$display_name,$member_id,$description,$ip) {
    
    //echo "This is the race". $race;
    //exit;
    
     if (isset($race) && $race ='0' && $race !== 'White' && $race !== 'Black'){
    
     	echo "This is an errror.!";
     	$t_error="19";
    	$member_id = $member_id;
    	notify_Admin($t_error,$member_id,$ip);				
       // logOut ($t_error);
    	exit;
    
    }
    
    
    
    

  10. Hello guys,

     

    I have a question about the logic of OR (||) and &&

     

    I have a form and on the form is asks for hair color

     

    <div class="hcenter"><div class="box3">Hair color</div></div>
    	<div class="box2"><input type="radio" name="hair" value="Black" />Black<br />
            <input type="radio" name="hair" value="Brunette" />Brunette<br />
            <input type="radio" name="hair" value="Blonde" />Blonde<br />
            <input type="radio" name="hair" value="Red" />Red<br /></div>
    
    

     

    I grab the post var  like this

     

    $hair = $_POST['hair']; // I actually have it filtered but you get the point

     

    I created this function

     

    function check_Haircolor($hair){
    if (isset($hair) && $hair != 'Brunette' || $hair != 'Black' ||  $hair != 'Red' || $hair != 'Blonde' ){				
    	 Do something here
    
    }
    
    }
    

     

    But it would not work correctly.. I kept doing the "Do something here...." so I tried the && and it worked (Se below) as expected. I would have bet that the or (||) would have been the correct code..

     

     

     

    
    function check_Haircolor($hair){
    if (isset($hair) && $hair != 'Brunette' && $hair != 'Black' &&  $hair != 'Red' && $hair != 'Blonde' ){				
    	 Do something here
    
    }
    
    }
    

     

     

    Why did the && word and not the ||

     

    Thanks,

    Dan

     

  11. Hello Guys,

     

    I am trying to strip the last comma but I can't get it to work... Please advise

     

    Here is my code, it adds the coma in between all numbers and on the end.

     

    $query1 = mysql_query("SELECT b_id FROM benefits");
    while ($row = mysql_fetch_array($query1)) {
    $b_id = $row['b_id'];
    
    $b_id . ",";
    
         echo $b_id2;
    
    }
    

     

    displays 1,2,3,4,5,6,7,8,9,10,

     

     

    I also tried this but it didn't work. It removed all the commas

     

    
    $query1 = mysql_query("SELECT b_id FROM benefits");
    while ($row = mysql_fetch_array($query1)) {
    $b_id = $row['b_id'];
    
    
    $b_id . ",";
    $b_id2 = rtrim($b_id,',');
         echo $b_id2;
    
    
    }
    
    

     

     

  12. Thanks for the quick response.

     

    I am trying to compare what is submitted form the form with whats in the database b_id column.

     

    I am developing a security system that basically looks at what has been submitted and compares it to whats in the database.. Will your code still work for that?

    ]

    Thanks!

  13. Hello Guys,

     

    I am trying to figure this out..

     

    I have a page that has several check boxes that when checked the values ends up as an array

    Like this

     

    1, 3, 9, 6,

     

    That's what it looks like in the database.

     

    I want to compare the values (numbers) submitted with the values in my database table called benefits

     

    Here is the function

     

    I wrote this function and I want to check the values of the submitted values but I am just not sure how to compare the values, especially with a comma in the array.

     

    
    $benefits2 = $_POST['benefits'];
    
    function check_benefits ($benefits2,$member_id,$description,$ip){
    $queryb = mysql_query("SELECT * FROM benefits WHERE b_id = $benefits2");
    while ($row = mysql_fetch_array($queryb)) {
    $benefit_list = $row['b_id'];
    }
    
    if (isset($benefits2)&&( $benefit_list!== $benefits2)) {
    
    	Do something here!
    }
    
    }
    

     

     

    Thanks for your help!

     

  14. Thanks for the quick response Ken. What if I wanted to check to just make sure that it's a valid email address in the function. Not necessarily a specific email address?

     

    For example here is one I done for the price

     

    function check_Price($price,$member_id,$description,$ip){
    if (!is_numeric($price))
    {
           $t_error="6";
       $member_id = $member_id;
    	notify_Admin($t_error,$member_id,$ip);				
    	logOut ($t_error);
    	exit;	
    }
    

  15. Hello Guys,

     

    I have a question about doing an IF statement in a function.

     

    Here is my code

     

    function checkEmail($email){
      return preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email) ? TRUE : FALSE;
    }
    
    

     

    How would I do the IF statement to test if the email is True or False?

     

    Is it like this?

     

    function checkEmail($email){
      return preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email) ? TRUE : FALSE;
    
    if ($email == "False") {
    Do something here
    }
    
    }
    
    

     

    Thanks for you help!

  16. Please take a look at my code here. It currently works, but I think there has to be a better way. Here is the process

     

    1. query the db for the list of bad words

    2. checking all post vars for bad words (Entering them in manually)

    3. Created an if statement to check is $var !== $var2

     

    There's got to be a better way to code this. If I have say 60 post vars it going to be very time consuming.. Any help will be appreciated.

     

    $search_for_bad_words = mysql_query("SELECT * FROM badwords WHERE 1");
    
      // Checking every post var for bad words
      $ad_title2 = $ad_title;
      $ad_body2  = $description;
      $subn2 = $subn;
      $price2 = $price;
      $viewname2 = $viewname;
      $display_name2 = $display_name;
      $email2 = $email;
      //$wordlist = "****:cr*p|dang:d*ng|shoot:sh**t";
      $seperate_text = "|";
      $entry_seperate_text = ":";
                                            
      while($row = mysql_fetch_array($search_for_bad_words))
      {
         $wordlist = $wordlist.$seperate_text.$row[word].$entry_seperate_text.$row[r_word];
      }
      $words = explode('|', $wordlist);
      foreach ($words as $word) {
      list($match, $replacement) = explode(':', $word);
      $ad_title2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $ad_title2);
      $ad_body2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $ad_body2);
      $subn2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $subn2);
      $price2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $price2);
      $viewname2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $viewname2);
      $display_name2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $display_name2);
      $email2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $email2);
      }
       
       
         
    
       // Checking to see if user used a bad word and is going to get an email and 
       // set a warning in the db
       if ($ad_title!==$ad_title2 || $description!==$ad_body2 || $subn!==$subn2 || $price!==$price2 || $viewname!==$viewname2 || $display_name!==$display_name2 || $email!==$email2) {
           
           $warning = "1";
    
       // Function sends error message  
       send_Warning();
       
       // Function sets number of warnings in database
        
       warning_Updatedb($warning,$member_id);
        
       }
       
      // Function to make sure that user cannot place any more ads if he/she is banned
       user_Ban($member_id);  
    
    
    

  17. Basically what I would like to do is some code in my filter to read all the post vars and if any contain something like http://www.spam.com or any web address to filter it out or do character replacement.

     

    Here's my filter

     

    function filter($data) {
        $data = trim(htmlentities(strip_tags($data)));
    
        if (get_magic_quotes_gpc())
            $data = stripslashes($data);
    
        $data = mysql_real_escape_string($data);
        
       return $data;
        
    }
    
    

     

    Here is my code calling the filter

     

    // Grab all POST vars and run them through the loop and filter
    
        $_POST = array_map('strip_tags', $_POST); 
        array_walk_recursive($_POST, 'filter');
        extract($_POST,EXTR_SKIP);
    
    

     

    Thanks for your help..

     

     

×
×
  • 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.