Jump to content

SkyRanger

Members
  • Content Count

    727
  • Joined

  • Last visited

Everything posted by SkyRanger

  1. lol, thanks Barand. I was able to test it and it worked. So now it is bilingual but not Multi at this time. Maybe down the road.
  2. Adding this should work should it not? À-ÿ regexp"=>"/^[a-zA-ZÀ-ÿ-\s]+$/
  3. Then I am in trouble because it never crossed my mind until you brought it up.
  4. Figured it out. Was putting the - in the wrong spot: options"=>array("regexp"=>"/^[a-zA-Z-\s]+$/")))){
  5. Having a validation issue when a person enters a - in there name it is kicking it back as invalid. For axample: Mary-Ann Invalid Mary Ann Valid Tried including the - but causing myself a lot of grief. function filterkudoagent($field){ // Sanitize user name $field = filter_var(trim($field), FILTER_SANITIZE_STRING); // Validate user name if(filter_var($field, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Z\s]+$/")))){ return $field; } else { return FALSE; } }
  6. Awesome Barand thank you. I also see what I can start it on any day. Again thank you. Much easier than what I was attempting to do and PS: This link in your signature. Still reading it over. Thank you
  7. I am currently working on a date range script and wondering if anybody think of an easier way to do this, doing up to next 8 weeks? This one starts on a Sunday. I also need to do one starting on a Monday (will figure that one later) $thisweek = date("Y-m-d"); $week = date('w', strtotime($thisweek)); $date = new DateTime($thisweek); $firstWeek = $date->modify("-".$week." day")->format("M d"); $endWeek = $date->modify("+6 day")->format("M d"); echo $firstWeek." - "; echo $endWeek; $nextweek = date(("Y-m-d"), strtotime("+7 Days")); $week1 = date('w', strtotime($nextweek)); $date1 = new DateTime($nextweek); $firstWeek1 = $date1->modify("-".$week1." day")->format("M d"); $endWeek1 = $date1->modify("+6 day")->format("M d"); echo $firstWeek1." - "; echo $endWeek1;
  8. Thank you to the both of you. I am almost 50, doing this late in life and self teaching with the help of great people like you. Thank you again.
  9. It does Barand. Thank you. Shows how much I know about sql. Did not know you could use a select within a select. Learning something new every day.
  10. Thanks Barand, I actually got it to work perfectly from the Sept 9th post you helped me with but been away for a bit and first time back to comment on benanamen post and try to solve another problem I posted in a different through with pulling random posts that I know I have done dozens of times but having a brain meltdown...lol
  11. Right now I have a little over 400 entries but I am trying to figure out how to only pull 1 entry from the last 10 inserted. Currently I have: SELECT * FROM $tablename ORDER BY RAND() LIMIT 1 I do know I need to do order by kuid asc but not sure how to pull 1 out of the last 10 inserted randomly on page refresh.
  12. Hi benanamen what I am doing is when an entry is submitted a random key is entered also for each entry
  13. I am trying to figure out how to populate a column that was added after the fact with this: function randkey($j = 10){ $string = ""; for($i=0; $i < $j; $i++){ $x = mt_rand(0, 2); switch($x){ case 0: $string.= chr(mt_rand(97,122));break; case 1: $string.= chr(mt_rand(65,90));break; case 2: $string.= chr(mt_rand(48,57));break; } } return $string; } This is what I currently have and you can guess how this turns out (same key in all rows): $randomkey = randkey(); $status = '1'; $wpdb->update( $sqltable, array( 'randkey' => $kudoomkey, ), array('status' => $status), array( '(%s)' ), array( '%d' ) );
  14. Thanks all for your help got it working and a special thanks again to barand, worked like I needed it to.
  15. Hi mac_gyver. For some reason not sure what happened with that script. It actually is(was) working in another part of my plugin but for some reason not sure if I typed something wrong in the new part of the program. I squashed the latest validation check above as it was causing nightmares. I am currently working on securing the validation as I got it working almost the way it is needed but still having a problem with one field. The account one that barand has provided assistance on. person leaves account field empty should not give error. When enters data into field check field to ensure they are only numbers. if (isset($_POST['account']) && ctype_digit($_POST['account'])) { // OK } else { $accountErr = "Only numbers are permitted or leave blank"; }
  16. Run in to a new issue and still having issue with code advised of Barand. Even if there are errors the info is still submitting to database and if somebody does not enter anything in the account field it is stating that is required. if( isset($_POST['submit']) ) { if(empty($_POST['kudoagent'])) $msg_name = "You must supply agent name"; $name_subject = $_POST['kudoagent']; $name_pattern = '/^[a-zA-Z ]*$/'; preg_match($name_pattern, $name_subject, $name_matches); if(!$name_matches[0]) $msg2_name = "Only alphabets and white space allowed"; if(empty($_POST['agentloc'])) $msg_agloc = "You must select a location"; if(empty($_POST['kudoclient'])) $msg_kclient = "You must select a queue"; if(empty($_POST['kudocust'])) $msg_custname = "You must supply customer name"; $custname_subject = $_POST['kudocust']; $custname_pattern = '/^[a-zA-Z ]*$/'; preg_match($custname_pattern, $custname_subject, $custname_matches); if(!$custname_matches[0]) $msg2_custname = "Only alphabets and white space allowed"; if(empty($_POST['kudomsg'])) $msg_kmsg = "You must enter a kudos"; if (isset($_POST['account']) && ctype_digit($_POST['account'])) { // Nothing to output } else { // ERROR $msg = "Only number are permitted"; } } if(isset($_POST['submit'])){ if($msg_name=="" && $msg2_name=="" && $msg_agloc=="" && $msg_kclient=="" && $msg_custname=="" && $msg2_custname=="" && $msg_kmsg=="") $msg_success = "Kudos has been submitted"; global $wpdb; $table = $tablename; $kudokey = randkey(); $kudoposted = date("Y-m-d H:i:s"); $data = array( 'kudoid' => '', 'kudomsg' => $_POST['kudomsg'], 'kudoagent' => $_POST['kudoagent'], 'kudoagentid' => $_POST['kudoagentid'], 'kudocust' => $_POST['kudocust'], 'kudoacct' => $_POST['kudoacct'], 'kudoclient' => $_POST['kudoclient'], 'kudoloc' => $_POST['agentloc'], 'kudoentry' => $kudoposted, 'kudoadmin' => $_POST['kudoadmin'], 'kudopic' => $_POST['kudobanner'], 'kudostatus' => '0', 'kudokey' => $kudokey, ); $format = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ); $success=$wpdb->insert( $table, $data, $format ); if($success){ /* echo "<blockquote class=\"otro-blockquote\">"; echo nl2br($_POST['kudomsg']); echo "<span>"; echo "<b>Kudos for:</b> " .$_POST['kudoagent']. " - " .$_POST['kudoagentid']. ", ".$_POST['agentloc']; echo "<br>By: ".$_POST['kudocust']. ", " . date("F j, Y g:i a", strtotime($kudoposted)); echo "<br/>" .$_POST['kudoacct']; echo "<br/> Submitted By: " .$_POST['kudoadmin']; echo "</span></blockquote>"; $urlparts = parse_url(home_url()); $kudourl = $urlparts['host']; */ echo "<div class='success_msg'>".$msg_success."</div>"; } }
  17. Sorry maxxd if( isset($_POST['submit']) ) { if(empty($_POST['kudoagent'])) $msg_name = "You must supply agent name"; $name_subject = $_POST['kudoagent']; $name_pattern = '/^[a-zA-Z ]*$/'; preg_match($name_pattern, $name_subject, $name_matches); if(!$name_matches[0]) $msg2_name = "Only alphabets and white space allowed"; if(empty($_POST['agentloc'])) $msg_agloc = "You must select a location"; if(empty($_POST['kudoclient'])) $msg_kclient = "You must select a queue"; if(empty($_POST['kudocust'])) $msg_custname = "You must supply customer name"; $custname_subject = $_POST['kudocust']; $custname_pattern = '/^[a-zA-Z ]*$/'; preg_match($custname_pattern, $custname_subject, $custname_matches); if(!$custname_matches[0]) $msg2_custname = "Only alphabets and white space allowed"; /*This is the issue part*/ if(empty($_POST['account'])) $acct_subject = $_POST['account']; $acct_pattern = '/^[0-9]*$/'; preg_match($acct_subject, $aact_matches); if(!$acct_matches[0]) $msg_acct = "Only numbers are allowed"; /*end of issue part*/ if(empty($_POST['kudomsg'])) $msg_kmsg = "You must enter a kudos"; } if(isset($_POST['submit'])){ if($msg_name=="" && $msg2_name=="" && $msg_agloc=="" && $msg_kclient=="" && $msg_custname=="" && $msg2_custname=="" && $msg_kmsg=="" && msg_acct=="") $msg_success = "Kudos has been submitted";
  18. I am working on a form validation script and not sure how to approach this. I can validate current entries that are required but I am trying to figure out how to validate an entry only if submitted and ignored if field is empty. /*form field*/ <input type="text" name="account"> <?php echo "<div class='note'>".$msg_acct."<br/>"; /*This is in the validation script*/ if(empty($_POST['account'])) $acct_subject = $_POST['account']; $acct_pattern = '/^[0-9]*$/'; preg_match($acct_subject, $aact_matches); if(!$acct_matches[0]) $msg_acct = "Only numbers are allowed";
  19. Thanks maxxd. Yeah once I get the bugs all worked out and start putting everything together I am am going to be securing the crap out of this thing. That is all I need is to leave an open hole for somebody to access a businesses server.
  20. Thank you guys. It was me who did a stupid and not watching what I was typing. Thanks for your help it is working perfectly now.
  21. echo "<table>"; echo "<form name='FormData' method='post' action=''>"; echo "<thead><th>Name</th><th>Email</th><th> <button type='submit' value='kudoemaildelete' class='formbutton' name='kudoemaildelete' />Delete</button> </th></thead>"; $kudolistem = $wpdb->get_results( "SELECT * from $tableemname where kuemqueue = '$kemail->kuemqueue'" ); foreach ($kudolistem as $kudosndem) { $kuemid = $kudosndem->kuemid; echo "<tr>"; echo "<td>" .$kudosndem->kuemname. " </td><td>" .$kudosndem->kuemaddy. "</td><td><center><input name='kuemid[]' type='checkbox' id='checkbox[]' value=" .$kuemid. "></center></td>"; echo "</tr>"; } echo "</form>"; echo "</table>"; It is probably something so stupid I am missing. I have tried both _POST and _GET
×
×
  • 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.