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
https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/
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;
?>

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>

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>";

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

 

 

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");

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>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.