Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Search a POST var

Posted on 2008-06-11
7
Medium Priority
?
187 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
Industry Leaders: 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

636 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