0

Im trying to create a php webpages to update information in an access database using a odbc connection the page1 sends the variable to page3 and displays the result page two allows you to pick which row to update then goes to the update page where i want text boxes to allow the user to input changes however from page3 to the update page its not giving me the results from the query Im thinking the id is not being passed using the $_GET Any Help would be appreciated.

Page1

<html>
<body>

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


<h1> Please Select Room to Update </h1>

<br>
<br>
<br>


<select name ="Room">
<option value="Chesapeake 10-12"> Chesapeake 10-12 </option>
<option value="Chesapeake 7-9 ">Chesapeake 7-9 </option>
<option value="Chesapeake E & F">Chesapeake E&F</option>
<option value="Gaylord Suite">Gaylord Suite</option>
<option value="Maryland Ballroom 1 & 2">Maryland Ballroom 1&2 </option>
<option value="Maryland Ballroom 3-6">Maryland Ballroom 3-6</option>
<option value="Maryland Ballroom A & B">Maryland Ballroom A&B</option>
<option value="Maryland Ballroom C">Maryland Ballroom C</option>
<option value="Maryland Ballroom C & D">Maryland Ballroom C&D</option>
<option value="Maryland Ballroom D">Maryland Ballroom D</option>
<option value="National Harbor 10">National Harbor 10</option>
<option value="National Harbor 10 & 11">National Harbor 10&11</option>
<option value="National Harbor 11">National 11</option>
<option value="National Harbor 2">National Harbor 2</option>
<option value="National Harbor 2 & 3">National Harbor 2&3</option>
<option value="National Harbor 3">National Harbor 3</option>
<option value="Potomac Ballroom 1-3">Potomac Ballroom 1-3 </option>
<option value="Potomac Ballroom 1-6 Foyer and Terrace">Potomac Ballroom 1-6 Foyer and Terrace</option>
<option value="Potomac Ballroom 4 & 5">Potomac Ballroom 4&5</option>
<option value="Potomac Ballroom A & B">Potomac Ballroom A&B</option>
<option value="Potomac Ballroom C">Potomac Ballroom C</option>
<option value="Potomac Ballroom C & D">Potomac Ballroom C&D</option>
<option value="Potomac Ballroom D">Potomac Ballroom D</option>
<option value="Potomac Ballroom Foyer">Potomac Ballroom Foyer</option>
<option value="Prince George Exhibit Hall D ">Prince George Exhibit Hall D</option>

 

 


 

<input type="submit" value = "Submit" />
</form>

</body>
</html>

Page3.php

<html>

<body>

<?php

$room = $_POST["Room"]; 



$conn=odbc_connect('Agenda','','');
$sql="SELECT * FROM Agenda WHERE Room = '$room '";
$rs=odbc_exec($conn,$sql); 



if (!$rs)
  {exit("Error in SQL");}
 
echo "<table><tr>";
//echo "<th>ID</th>";
//echo "<th>End Time Central</th>";
//echo "<th>Day</th>";
//echo "<th>Date</th>";
//echo "<th>Start Time</th>";
//echo "<th>End Time</th>";
//echo "<th>Room</th>";
//echo "<th>Meeting Title</th></tr>";

while (odbc_fetch_row($rs))
{
    echo '<form action="update.php" method="post">';
  $id=odbc_result($rs,1);
  $endtime=odbc_result($rs,2);
  $days=odbc_result($rs,3);
  $date=odbc_result($rs,4);
  $start=odbc_result($rs,5);
  $end=odbc_result($rs,6);
  $room=odbc_result($rs,7);
  $title=odbc_result($rs,8);
echo "<tr><td><strong>ID:</strong> $id</td>";
echo "<tr><td><strong>End Time Central:</strong> $endtime</td>";
echo "<tr><td><strong>DAY:</strong>  $days</td>";
echo "<tr><td><strong>Date:</strong> $date</td>";
echo "<tr><td><strong>Start Time:</strong>$start</td>";
echo "<tr><td><strong>End Time:</strong> $end</td>";
echo "<tr><td><strong>Room:</strong> $room</td>";
echo "<tr><td><strong>Title:</strong> $title</td>";
echo "<tr><td></td>";
echo "<td></td></tr>";

//echo '<td align="center"><a href="update.php?id='; echo $ids; echo '"><strong>UPDATE</strong></a></td>
//</tr>';
echo '<td align="center"><input type="submit" value = "Update" /></td></tr>';
echo "<td></td></tr>";
echo "<td></td></tr>";
echo "<td></td></tr>";
echo "<td></td></tr>";
echo "<td></td></tr>";
echo "<td></td></tr>";
  
  
  echo'</form>';
 }
 odbc_close($conn); 
 echo "</table>";




?>




</table>




</body>
</html>

update.php

<HTML>
<BODY>
<?


$conn=odbc_connect('Agenda','','');

$id= $_POST["id"];

$sql="SELECT * FROM Agenda WHERE Id = $id ";
$rs=odbc_exec($conn,$sql); 
;
if (!$rs)
  {exit("Error in SQL");}
 
echo "<table><tr>";

while (odbc_fetch_row($rs))
  {
  $idd=odbc_result($rs,1);
  $endtime=odbc_result($rs,2);
  $days=odbc_result($rs,3);
  $date=odbc_result($rs,4);
  $start=odbc_result($rs,5);
  $end=odbc_result($rs,6);
  $room=odbc_result($rs,7);
  $title=odbc_result($rs,8);
  
 echo $idd;
 
echo "<tr><td><strong>ID:</strong> $idd</td>";
echo "<tr><td><strong>DAY:</strong>  $days</td>";
echo "<tr><td><strong>Date:</strong> $date</td>";
echo "<tr><td><strong>Start Time:</strong>$start</td>";
echo "<tr><td><strong>End Time:</strong> $end</td>";
echo "<tr><td><strong>Room:</strong> $room</td>";
echo "<tr><td><strong>Title:</strong> $title</td>";
echo "<tr><td></td>";
echo "<td></td></tr>";



}
 odbc_close($conn); 
 echo "</table>";
  



?>


</BODY>
</HTML>

Edited by twoods99: n/a

4
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by cwarn23
0

try using $_REQUEST until you've figured it out, perhaps $_POST.

Add some debugging in. To the top of the page add:

echo '<pre>';
print_r($_REQUEST);
echo '</pre>';

This will show you what data is being passed to the page... by either POST or GET.

0

>> Line 12 of update.php has a bug in it.
>> SQL Injections on your sql queries
And I'm not much of an odbc fan but I think you should be using some debugging methods to see what type of sql errors might be comming from the sql string. For example, in mysql the function is mysql_error(). Also I must mention that while $_REQUEST may be used for debugging it isn't a good variable to use. It is by far better to use $_POST and $_GET in its place. Thought I would let you know. :)

0

i did mean to bold "until you've figured it out", but forgot :)

I was just mentioning it because it couldn't be stressed enough and you would be surprised how many people just copy and paste then skip most of the words unless something goes wrong. :)

Votes + Comments
so true
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.