Solved

Search a POST var

Posted on 2008-06-11
7
180 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 50

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now