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
Share on other sites

Dare i be so rude as to ask whether in submitbid.php you are connecting to the database?

 

Additionally for your  VALUES('$pilotid'

 

i would reccomend doing the following VALUES({$pilotid}

 

to prevent injection since this is "monetary".

Link to comment
Share on other sites

Then please try this:

 

$result = mysql_query($sql);

if($result) {
  echo "Success...";
}
else {
  echo "Failure...";
}

 

Just to see what the result of the query is, if it returns true as in success or false as in failure...

Link to comment
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
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
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
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
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.