Post and get at the same time in php
Posted
by user225269
on Stack Overflow
See other posts from Stack Overflow
or by user225269
Published on 2010-05-01T09:20:06Z
Indexed on
2010/05/01
9:27 UTC
Read the original article
Hit count: 213
Do you have any suggestions with my problem. I need to use get and post at the same time. Get because I need to output what the user has typed. And post because I need to access the mysql database in relation to that input. It looks something like this:
<form name="x" method="get" action="x.php">
<input name="year" type="text">
<select name="general" id="general">
<font size="3">
<option value="YEAR">Year</option>
</form>
This will output the contents of mysql depending on what the user will check:
<form name="y" method="post" action"y.php">
<input name="fname" type="checkbox">
</form>
And the form action of those two combined will look something like this:
<?php
if($_POST['general'] == 'YEAR'){
?>
<?php echo $_GET["year"]; ?>
<?php
$result2 = mysql_query("SELECT * FROM student
WHERE student.YEAR='$syear'");
?>
<table border='1'>
<tr>
<?php if ( $ShowLastName ) { ?><th>LASTNAME</th><?php } ?>
<?php if ( $ShowFirstName ) { ?><th>FIRSTNAME</th><?php } ?>
</tr>
<?php while ( $row = mysql_fetch_array($result2) ) {
if (!$result2) {
}
?>
<tr>
<td><?php echo $row['IDNO']?> </td>
<td><?php echo $row['YEAR'] ?> </td>
<?php if ( $ShowLastName ) { echo('<td>'.$row['LASTNAME'].'</td>'); } ?></td>
<?php if ( $ShowFirstName ) { echo('<td>'.$row['FIRSTNAME'].'</td>'); } ?>
I really get lots of undefined errors when I do this. What can you recommend that I should do in order to get the value inputted by the user together with the mysql data.
© Stack Overflow or respective owner