TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,026
  • Total Topics: 21,333
  • Online today: 899
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 419
  • Total: 419

PHP Question

Started by TimUSA, April 15, 2008, 01:39:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TimUSA

I have a PHP question, but it is not support, or block request material, so i hope is is ok to post this here?

I am developing an online employment application for my company and i want to require the user to post at least one employment reference. so i have for example $_POST['emp1'] , $_POST['emp1add'] , $_POST['emp1phone'] ect ect ect. Instead of checking each field individually can I do something like this?

if (empty($_POST['emp1*']))
{
execute code
}

If not any suggestions?

JPDeni

No, you can't do that. You can do something like:


$form = $_POST;
$test = 0;
foreach ($form as $key => $value)
{
  if (substr($key,0,4) == 'emp1') && empty($value)
    $test=1;
}
if ($test == 1)
{
  execute code
}


I think. :)

TimUSA

thanks JP I'll give that a try

This website is proudly hosted on Crocweb Cloud Website Hosting.