Jump to content

extract details from same post field


mysterbx

Recommended Posts

Helllo,

 

How can I extract data from $_post['type'] if they are two of them...

 

more simplified (html sample)

<tr><td>1)</td><td><input name="title[]" size="50" maxlength="72" id="dt0" onchange="donh(this.id);" type="text"></td>
<td><input name="url[]" size="30" id="du0" onchange="donh(this.id);" type="text"></td>

<td><select name="type[]" id="se0" onchange="donh(this.id);"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td>2)</td><td><input name="title[]" size="50" maxlength="72" id="dt1" onchange="donh(this.id);" type="text"></td>
<td><input name="url[]" size="30" id="du1" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se1"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td>3)</td><td><input name="title[]" size="50" maxlength="72" id="dt2" onchange="donh(this.id);" type="text"></td>
<td><input name="url[]" size="30" id="du2" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se2"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td>4)</td><td><input name="title[]" size="50" maxlength="72" id="dt3" onchange="donh(this.id);" type="text"></td>

<td><input name="url[]" size="30" id="du3" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se3"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td>5)</td><td><input name="title[]" size="50" maxlength="72" id="dt4" onchange="donh(this.id);" type="text"></td>
<td><input name="url[]" size="30" id="du4" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se4"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td>6)</td><td><input name="title[]" size="50" maxlength="72" id="dt5" onchange="donh(this.id);" type="text"></td>
<td><input name="url[]" size="30" id="du5" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se5"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td>7)</td><td><input name="title[]" size="50" maxlength="72" id="dt6" onchange="donh(this.id);" type="text"></td>

<td><input name="url[]" size="30" id="du6" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se6"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td></td><td><input name="title[]" size="50" maxlength="72" id="dt7" onchange="donh(this.id);" type="text"></td>
<td><input name="url[]" size="30" id="du7" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se7"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td>9)</td><td><input name="title[]" size="50" maxlength="72" id="dt8" onchange="donh(this.id);" type="text"></td>
<td><input name="url[]" size="30" id="du8" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se8"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr>

<tr><td>10)</td><td><input name="title[]" size="50" maxlength="72" id="dt9" onchange="donh(this.id);" type="text"></td>

<td><input name="url[]" size="30" id="du9" onchange="donh(this.id);" type="text"></td>
<td><select name="type[]" id="se9"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr></tbody></table>

Link to comment
Share on other sites

  • 2 weeks later...

it worked, but how can i check if one of 3 fields werent filled...

 

 

example:

 

type:
1-type
2-type
3-type

title
1-sometitle
2-
3-sometitle

url
1-http://
2-http://
3-

 

but there will be more than 3 fields.... it can be 50 or 60 or 61, its a random number...

 

the operation should fail...

 

it should be complete when all fields are filled...

 

example

type:
1-type
2-type
3-type

title
1-sometitle
2-sometitle
3-sometitle

url
1-http://
2-http://
3-http://

Link to comment
Share on other sites

Try this:

 

<?php

if (isset($_POST['your_submit_button'])){

   foreach ($_POST['type'] as $key => $val){
   
      $val = trim($val);
      if ($val == "") $error[] = "You left $key blank";
      
   }
   
   if (!empty($error)){
      foreach ($error as $err){
         echo $err.'<br>';
      }
   } else {
      echo "Everything was filled out correctly";
   }
   
}

?>

Link to comment
Share on other sites

it would work if i would have only one post field "type",

but now i have 3 of them, "title/type/url"

...

 

if first title is filled, url too, and type everything is ok,

but if first title is filled, url is empty, type filled, everything should fail (error should output)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.