Jump to content

[SOLVED] Form Problem


shadowspy1

Recommended Posts

I have been making great progress till this point. I've been stuck here for two days. My code doesn't not want to insert into he MYSQL database, although I have various other code throughout my site that does. Maybe I just overlooked somethng.

 

Here is the main form:

elseif ($section == 'flight'){
?>
<label>
<div align="center">
<form name="bidprocess" method="get" action="submitbid.php">
<center><p>
  <?
$sql = "SELECT * FROM availbid WHERE flightnum = '$flight'";
$result = mysql_query($sql);

$stats = mysql_fetch_array($result);
?>
  You are about to submit the following bid:</p>
</center>
<table width="516" border="0" align="center">
   	    <tr>
          <td width="216" bgcolor="#FFFFFF" class="style1"><div align="right"><span class="style5">Flight:</span></div></td>
          <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["flightnum"];?></span></td>
   	    </tr>
<tr>
  <td class="style5"><div align="right">Departing:</div></td>
  <td width="290" class="style1"><span class="style1"><? echo $stats["departure"];?></span></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><div align="right"><span class="style5">
  Departure Time:</span></div></td>
<td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["deptime"];?></span></td>
</tr>
<tr>
  <td bgcolor="#FFFFFF" class="style5"><div align="right">Arriving:</div></td>
  <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["arrival"];?></span></td>
</tr>
<tr>
  <td bgcolor="#FFFFFF" class="style5"><div align="right">Arrival Time:</div></td>
  <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["arrtime"];?></span></td>
</tr>
<tr>
  <td bgcolor="#FFFFFF" class="style5"><div align="right">Aircraft:</div></td>
  <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["equipment"];?></span></td>
</tr>       
     </table>

<?

if(isset($pilotid)){
?>




<input type="submit" name="Submit" value="Submit Bid">
</label>
<?


}

}
?>

 

Followed by the action script:

<?php
$pilotid = $_SESSION['pilotid'];
$flight = $_GET['flightnum'];
$aircraft = $_GET['equipment'];
$departure = $_GET['departure'];
$deptime = $_GET['deptime'];
$arrival = $_GET['arrival'];
$arrtime = $_GET['arrtime'];


$sql = "INSERT INTO takenbid (pilotid,flightnum, equipment, departure, deptime, arrival, arrtime) VALUES('$pilotid','$flightnum','$equipment','$departure','$deptime','$arrival','$arrtime')";
mysql_query($sql)

?>

Link to comment
https://forums.phpfreaks.com/topic/58953-solved-form-problem/
Share on other sites

I was trying something before I realized where to post it. I changed it back to the original and posted the code that you suggested. That's why you see that modified one in his quote. I realized my mistake.

 

SQL=INSERT INTO takenbid (pilotid, flightnum, equipment, departure, deptime, arrival, arrtime) VALUES('100','','','','','','')

Link to comment
https://forums.phpfreaks.com/topic/58953-solved-form-problem/#findComment-292912
Share on other sites

Scrub that I read teng's reply and misread it.

 

Now you can see that your INSERT isn't adding any data because the patr of the script that reads the data isn't working.

 

You've got the form set to GET which is correct but I can't see where you're building the input tags for the form?

Link to comment
https://forums.phpfreaks.com/topic/58953-solved-form-problem/#findComment-292913
Share on other sites

Yes unless you're getting data from a form?

 

I see you're pulling data from a table at the start of your first script but going by the form you've set up you've only created a submit button - nowhere to supply input.

 

You can either passthe data in the URL (insecure as users can simply edit the URL) or by sending via $_POST as packets of data when they click the submit button.

Link to comment
https://forums.phpfreaks.com/topic/58953-solved-form-problem/#findComment-292919
Share on other sites

Here's an example to get you going...

 

<td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["flightnum"];?></span><input type="hidden" name="flightnum" value="<?=$stats['flightnum']?>" /></td>

 

It's 3:15am now amd I'm having to get some sleep...

Link to comment
https://forums.phpfreaks.com/topic/58953-solved-form-problem/#findComment-292926
Share on other sites

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.