[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Search a POST var

Posted on 2008-06-11
7
Medium Priority
?
188 Views
Last Modified: 2010-04-21
How could you search a post (that was like below in the code area it's $_POST["dataArray"] )  so i could do something like this:

function screachPOST() {
foreach(PostItem) {
if "Pick" is there {
            send error
            form="notComplete";
      }else{
            form="complete";
}
if "na" is there{
            send error
            form="notComplete";
      }else{
            form="complete";
}
if is not a phone number {
            send error
            form="notComplete";
      }else{
            form="complete";
}

if form="complete" {
 send email();
 send completed message
}

This is a POST that comes from flash if it makes a diff and if someone wanted to go the distance how to send the error back would be nice as well... I'm open to ideas here, I just have to work with the one string of var...

I have another post that relates to this as well if it would help with this...
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23477927.html

Thank you for the help
jeremyBass
{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:pick},{Job_Picks`0|Unit Secretary Medical Unit},{Job_Picks`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}

Open in new window

0
Comment
Question by:jeremyBass26
  • 5
  • 2
7 Comments
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21765562
if it helps here is what i have so far on the flash side
var emailResponse:LoadVars = new LoadVars();
    emailResponse.onLoad = function(success:Boolean) {
    if (success) {
            debug_txt.text = this.result;
				ExternalInterface.call("formSubmit");
	trace("Submited");
	trace(postVars.dataArray);
    } else {
            debug_txt.text = "error downloading content";
    }
    };
    var postVars:LoadVars = new LoadVars();
    postVars.dataArray = FullArray;
    postVars.sendAndLoad("examples/example_011.php", emailResponse, "POST");

Open in new window

0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 21773376
I don't know anything about the flash side, but here's one way to validate in PHP:
<?
$form_complete=TRUE;
$err_msg = '';
$my_fields=array('namefield','datefield','phonefield','otherfield');
foreach ($my_fields as $checkfield) {
  if (!isset($_POST['checkfield'])) { $form_complete=FALSE; $err_msg="Need $checkfield!\n"; }
  // you can validate individual keys here
  // at each step, if anything is wrong, set $form_complete=FALSE
  // and put a reason in $err_msg
  switch ($checkfield) {
    case 'namefield': // check for name validity
      break;
    case 'datefield': // check for date validity
      break;
    case 'phonefield': // check for phone format
      break;
    case 'otherfield': // check for whatever
      break;
  }
}
if (!$form_complete) {
  // something went wrong
  $_SESSION['error_message'] = $err_msg;
  header('location:back_to_my_form.php');
  die();
}
// otherwise, everything is yay.  Get it done.
?>

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21773498
if the data that is sent to php... the var was = to:

{em_data_rec_v:na},{em_data_rec_d:na},{em_data_rec_di:na},{appstate_cb:pick},{Job_Picks`0|Unit Secretary Medical Unit},{Job_Picks`1|UNIT SECRETARY - SURGICAL UNIT},{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}
 

would what your sugesting pick out em_data_rec_v (which is the name to which has the value of na)
or just 'Job_Picks' ?

if yes how would you look in to this?
{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}

where it's   "Name"|"Value",    ?

your right it is to validate ... i should have put that up... thanks for the help here...


code \n
{em_data_rec_v:na},
{em_data_rec_d:na},
{em_data_rec_di:na},
{appstate_cb:pick},
{Job_Picks`0|Unit Secretary Medical Unit},
{Job_Picks`1|UNIT SECRETARY - SURGICAL UNIT},
{row|0,employer|asdf,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Thu Jun 5 00:00:00 GMT-0700 2008,to|Fri Jun 13 00:00:00 GMT-0700 2008,reason|asdf},
{row|1,employer|new Employee,address|asdf,phone|asdf,supervisor|asdf,contact|false,wage|asdf,duties|asdf,from|Mon Jun 9 00:00:00 GMT-0700 2008,to|Mon Jun 2 00:00:00 GMT-0700 2008,reason|asdf}

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 21784248
Tricky.  The easiest way would be with the PCRE functions.  Take a look at them here:

http://www.php.net/manual/en/ref.pcre.php

Specifically, take a look at preg_match_all().  Here's a possible untested example for you:
<?
$pattern='/\{([^}]+)\},?/';
$search=$the_data_you_posted_last
$matches=array();
 
$match=preg_match_all($pattern,$search,$matches);
// $matches[0][0] should be '{em_data_rec_v:na},'
// $matches[0][1] should be 'em_data_rec_v:na'
// $matches[1][0] should be '{em_data_rec_d:na},'
?>

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21784275
Looks like a promising route... i'll get back on this... :)
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 21817476
I have been going rounds on this... and have got no ware fast lol... but
FYI... I will be out after 4pm PST and will be gone for my son's surgery for the next four days... so I will not be able to do much if any thing...
thanks again...
jeremyBass
0
 
LVL 4

Author Closing Comment

by:jeremyBass26
ID: 31466419
sorry for the delay... thanks for the help
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question