Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:27:57+00:00 2026-06-06T23:27:57+00:00

php code if(empty($_POST) === false) { $required_fields = array(‘s_group’, ‘s_choice’); foreach($_POST as $key=>$value) {

  • 0

php code

if(empty($_POST) === false)
{
    $required_fields = array('s_group', 's_choice');
    foreach($_POST as $key=>$value)
    {

        if(empty($value) && in_array($key, $required_fields) === true)
        {
            $error = 'All * fields are required';
            break 1;
        }

    }


    if(empty($error) === true)
    {
        echo $_POST['s_group'];
        echo $_POST['s_choice'];
        echo $_POST['choice1'];
        echo $_POST['choice2'];
    }
}

echo $error;

This is html code

<form action="create_room.php" method="post" name="form1">
<select name="s_group">
    <option value=""><-- Please Select Item --></option>
    <?
    $strSQL = "SELECT * FROM room_group_options ORDER BY op_id";
    $objQuery = mysql_query($strSQL);
    while($objResult = mysql_fetch_array($objQuery))
    {
    ?>
    <option value="<?=$objResult["op_id"];?>"><?=$objResult["group"];?></option>
    <?
    }
    ?>
  </select>

  <script src="http://code.jquery.com/jquery-latest.js"></script>

 <p>Number of Choice :
 <select id="pagelist" name = "s_choice">
     <option value=""><-- Please Select Item --></option>
     <option value="twoChoices">2 Choices</option>
     <option value="threeChoices">3 Choices</option>
     <option value="fourChoices">4 Choices</option>
     <option value="fiveChoices">5 Choices</option>
 </select>

 <div id="twoChoices" style="display:none">

  Insert your choice<br>
  1:<input type="text" name="choice1" /><br />
  2:<input type="text" name="choice2" /><br /> 

 </div>

 <div id="threeChoices" style="display:none">

    Insert your choice<br>
    1:<input type="text" name="choice1" /><br />
    2:<input type="text" name="choice2" /><br /> 
    3:<input type="text" name="choice3" /><br /> 

 </div>


  <script language="javascript">
  $("#pagelist").change(function()
  {
    var viewID = $("#pagelist option:selected").val();
    $("#pagelist option").each(function()
    {
        var hideID = $(this).val();
        $("#"+hideID).hide();
    });
    $("#"+viewID).show();   
  });
</script>

<input type="submit" name "submit" value="Create">
</form>

I am a PHP newbie. After fill all blank, selected choice and hit submit button the value from s_group and s_choice are in $_POST but choice1 and choice2 aren’t come.

How can I get these value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:27:59+00:00Added an answer on June 6, 2026 at 11:27 pm

    Rewrite the following code
    Insert your choice

    1:<input type="text" name="choice1" value = ""/><br />
    2:<input type="text" name="choice2" value = ""/><br /> 
    

    Insert your choice<br>
    1:<input type="text" name="choice3" value = ""/><br />
    2:<input type="text" name="choice4" value = ""/><br /> 
    3:<input type="text" name="choice5" value = ""/><br /> 
    

    And dont duplicate your names of choices. Make your javascript in such a way that it will show/hide choice3, choice4 and choice 5 button on pagelist change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my entire PHP code: <?php if(empty($_POST['selid'])) {echo no value selected; } else
I have the following code validation php script: if(empty($_POST['captcha_code'])) { $error = 1; $code[3]
i have the following piece of code in php: define('QUERY', $some_query_string); if(empty(QUERY) || mb_strlen(QUERY)
I have this code that works well: {livre:empty_name} $.ajax({ url: sent.php, type: post, dataType:
PHP code: echo date(c); //out put like this 2012-06-19T20:37:44+05:30 echo date(d M, Y); //out
PHP code: <a id=a$id onclick=check($id,1) href=javascript:void(0) class=black>Qualify</a> I want to remove the onclick=check($id,1) so
Having php code: function getChildren($parent_id = 0) { .... return $SomeChildrenArray; } And Smarty
My PHP code is: $query=select company_name from company_names where cik=.$cik; Which on printing gives
My PHP code $dom = new DOMDocument(); @$dom->loadHTML($file); $xpath = new DOMXPath($dom); $tags =
My PHP code is split between many files, and often I find myself using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.