Jump to content

i am not able to post.. why ?


ferlicia

Recommended Posts

this is the form for my assignment

 

Criteria:

<form method="post" action="doSelectCriteria.php">

<select name="criteria">

<option value="selectCriteria">Select Criteria</option>

<option value="GPA">GPA</option>

<option value="Diploma">Diploma</option>

<option value="Gender">Gender</option>

<option value="LearningAttitudes">Learning Attitudes</option>

</select>

</form><br><br>

 

Additional Criteria:

<form method="post" action="doSelectCriteria.php">

<p><label for="criteria">Criteria Name: </label>

<input name="criteria" type="text"></p>

 

 

 

<p><input name="btnsubmit" value="Submit" type="submit"></p>

 

</form> <br>

 

next page (to carry out the selection )

    $criteria = $_POST['criteria'];

but when i echo to see the $criteria that i have selected, it is not shown

why? is there any error?

 

 

Link to comment
Share on other sites

<form method="post" action="">
<select name="criteria">
<option value="selectCriteria">Select Criteria</option>
<option value="GPA">GPA</option>
<option value="Diploma">Diploma</option>
<option value="Gender">Gender</option>
<option value="LearningAttitudes">Learning Attitudes</option>
</select>
<input type="submit" />
</form><br><br>
<?php
$criteria = $_POST['criteria'];
echo $criteria;
?>

Link to comment
Share on other sites

you need to  put a hidden field inside your form

 

 

<form method="post" action="doSelectCriteria.php">
<input type="hidden" name="criteria" value="<?=$_POST['criteria'];?>"  />
<select name="criteria">
<option value="selectCriteria">Select Criteria</option>
<option value="GPA">GPA</option>
<option value="Diploma">Diploma</option>
<option value="Gender">Gender</option>
<option value="LearningAttitudes">Learning Attitudes</option>
</select>
<input type="submit" />
</form>

Link to comment
Share on other sites

you could also use sessions if preferred over hidden fields.  ;)

$options=array();
$options['SelectCriteria'];
$options['GPA'];
$options['Diploma'];
$options['Gender'];
$options['LearningAttitdes'];

$_SESSION['criteria'] = (isset($_POST['critieria']) ? !empty($_POST['criteria') : $_SESSION['criteria']);
echo"<select name="criteria">";

foreach($option as $key => $val) 
{
echo "<option" . ($val == $_SESSION['criteria'] ? " selected" : "") . ">$val</option>"; 
}
echo "</select>";

Link to comment
Share on other sites

the criteria are still not posted..

this was my whole form

<form method="post" action="doSelectCriteria.php">

    <input type="hidden" name="criteria" value="<?=$_POST['criteria'];?>"  />

    <select name="criteria"><option value="selectCriteria">Select Criteria</option>

        <option value="GPA">GPA</option><option value="Diploma">Diploma</option>

        <option value="Gender">Gender</option>

        <option value="LearningAttitudes">Learning Attitudes</option>

    </select>

</form>

Additional Criteria:

<form method="post" action="doSelectCriteria.php">

<p><label for="criteria">Criteria Name: </label>

<input name="criteria" type="text"></p>

 

 

 

<p><input name="btnsubmit" value="Submit" type="submit"></p>

 

</form> <br>

 

 

then for the next page

 

  $criteria = $_POST['criteria'];

 

 

 

                $result_1= mysqli_query($link, "SELECT * FROM studentdetails, criteria WHERE studentdetails.StudentID = criteria.StudentID ORDER BY gpa ASC");

 

i am not able to post the result that have been choosen

and for the query, i wanted to order by the the criteria that i  have choosen instead of gpa, but there will be error

 

please help

 

 

Link to comment
Share on other sites

change this:

<input type="hidden" name="criteria" value="<?=$_POST['criteria'];?>"  />

 

to this:

<input type="hidden" name="criteria" value="<?php echo $_POST['criteria'];?>"  />

 

also try to echo criteria and see if gets a value

$criteria = $_POST['criteria'];
echo $criteria;//test echo criteria


                $result_1= mysqli_query($link, "SELECT * FROM studentdetails, criteria WHERE studentdetails.StudentID = criteria.StudentID ORDER BY gpa ASC");

Link to comment
Share on other sites

sorry there is still codes after the form in the same page

 

<?php

 

include 'dbFunctions.php';

 

$fields = mysqli_list_fields("fyp", "criteria", $link);      there is an error in this line: Fatal error: Call to undefined function mysqli_list_fields()

$columns = mysqli_num_fields($fields);

 

?>

 

<form method="post" action="doSelectCriteria.php">;

<select name = criteria>;

 

<?php

for ($i = 0; $i < $columns; $i++) {

echo "<option value='".mysqli_field_name($fields, $i)."'>";

echo mysqli_field_name($fields, $i);

}

echo "</select>";

?>

<input name="btnsubmit" value="Submit" type="submit"></p>;

</form>

 

</div>

    </body>

</html>

 

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.