Solved

Search a POST var

Posted on 2008-06-11
7
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

724 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