Member Avatar for begueradj

Hello,

I have a form from which I post some data into 3 tables: when I click on the submit button I don't get any error message from mysql_error(); but when I look to my 3 tables I see no one of them has received the data I just posted :(

Please, help me, here is my code:

<?php
require_once('Includes/header.inc.php');
?>
<div id="proformacontent">
<p align="center" class="letitre">Proforma Request</p>
<?php
if(isset($_POST['proformabt'])){
	if(!empty($_POST['vesselname'])&&!empty($_POST['gt'])&&!empty($_POST['nt'])&&!empty($_POST['dwt'])&&!empty($_POST['loa'])&&!empty($_POST['beam'])&&!empty($_POST['summerdraft'])&&!empty($_POST['flag'])&&!empty($_POST['owner'])&&!empty($_POST['from'])&&!empty($_POST['to'])&&!empty($_POST['natureofcargo'])&&!empty($_POST['quantityofcargo'])&&!empty($_POST['terms'])&&!empty($_POST['company'])&&!empty($_POST['namepic'])&&!empty($_POST['phone'])){
		
		$vesselname=htmlentities(stripslashes($_POST['vesselname']));
		$gt=htmlentities(stripslashes($_POST['gt']));
		$nt=htmlentities(stripslashes($_POST['nt']));
		$dwt=htmlentities(stripslashes($_POST['dwt']));
		$loa=htmlentities(stripslashes($_POST['loa']));
		$beam=htmlentities(stripslashes($_POST['beam']));
		$summerdraft=htmlentities(stripslashes($_POST['draft']));
		$flag=htmlentities(stripslashes($_POST['flag']));
		$owner=htmlentities(stripslashes($_POST['owner']));
		
		$from=htmlentities(stripslashes($_POST['from']));
		$to=htmlentities(stripslashes($_POST['to']));
		$natureofcargo=htmlentities(stripslashes($_POST['natureofcargo']));
		$quantityofcargo=htmlentities(stripslashes($_POST['quantityofcargo']));
		$terms=htmlentities(stripslashes($_POST['terms']));
		
		$company=htmlentities(stripslashes($_POST['company']));
		$namepic=htmlentities(stripslashes($_POST['namepic']));
		$phone=htmlentities(stripslashes($_POST['phone']));
		$mobile=htmlentities(stripslashes($_POST['mobile']));
		$fax=htmlentities(stripslashes($_POST['fax']));
		
		$today=$_POST['ladate'];
		$distinguish=$_POST['distinguish'];
		
		include('Cfg/config.inc.php');
		
		$aplink=mysql_connect($SERVER,$USER,$PWD)or die('Impossible to connect to MySQL Server<br/>'.mysql_error());
		$mysql_select_db($DB)or die('Impossible to select the requested database<br/>'.mysql_error());
		
		
		mysql_query("INSERT INTO vessels (vesselname,gt,nt,dwt,loa,beam,summerdraft,flag,owner,disinguish)VALUES ('$vesselname','$gt','$nt','$dwt','$loa','$beam','$summerdraft','$flag','$owner','$distinguish')")or die('Insertion problem<br/>'.mysql_error());
		mysql_query("INSERT INTO cargo (from,to,natureofcargo,quantityofcargo,terms,disinguish)VALUES ('$from','$to','$natureofcargo','$quantityofcargo','$terms','$distinguish')")or die('Insertion problem<br/>'.mysql_error());
		mysql_query("INSERT INTO customer (company,namepic,phone,mobile,fax,disinguish)VALUES ('$company','$namepic','$phone','$mobile','$fax','$distinguish')")or die('Insertion problem<br/>'.mysql_error());
		
		
		
		
		
	}else{
		echo'At least one of the fields is empty';
	}
}
?>
<?php
$distinguish=0;
?>
<form action="proforma.php"method="post">
<table align="center" id="proformatable">
  <TR>
   <th colspan="2">Vessel's  Details</th><th bgcolor="#7AB8F5" widht="5"></th><th colspan="2">Cargo's Details</th>
  </TR>
  <TR>
   <td>Vessel's name:</td><td><input type="text" name="vesselname"/><td bgcolor="#7AB8F5" width="5"></td></td><td>From:</td><td><input type="text" name="from"/></td>
  </TR>
  
  <TR>
   <td>GT:</td><td><input type="text" name="gt"/><td bgcolor="#7AB8F5" width="5"></td></td><td>To:</td><td><input type="text" name="to"/></td>
  </TR>
  
  <TR>
   <td>NT:</td><td><input type="text" name="nt"/><td bgcolor="#7AB8F5" width="5"></td></td><td>Nature of Cargo:</td><td><input type="text" name="natureofcargo"/></td>
  </TR>
  
  <TR>
   <td>DWT:</td><td><input type="text" name="dwt"/><td bgcolor="#7AB8F5" width="5"></td></td><td>Quantity of Cargo:</td><td><input type="text" name="quantityofcargo"/></td>
  </TR>
  
  <TR>
   <td>LOA:</td><td><input type="text" name="loa"/><td bgcolor="#7AB8F5" width="5"></td></td><td>Terms:</td><td><input type="text" name="terms"/></td>
  </TR>
  
  <TR>
   <td>BEAM:</td><td><input type="text" name="beam"/></td><td bgcolor="#7AB8F5" width="5"></td><td></td><td></td>
  </TR>
  
  <TR>
   <td>Summer Draft:</td><td><input type="text" name="summerdraft"/></td><td bgcolor="#7AB8F5" width="5"></td><td></td><td></td>
  </TR>
  
  <TR>
   <td>Flag:</td><td><input type="text" name="flag"/></td><td bgcolor="#7AB8F5" width="5"></td><td></td><td></td>
  </TR>
  
  <TR>
   <td>Owner:</td><td><input type="text" name="owner"/></td><td bgcolor="#7AB8F5" width="5"></td><td></td><td></td>
  </TR>
  <tr>
  <th colspan="5">Customer's Details</th>
  </tr>
  
  <TR>
   <td colspan="3">Company <font color="orange">*</font>:</td><td colspan="2" align="right"><input type="text" name="company"/></td>
  </TR>
  
   <TR>
   <td colspan="3">Name PIC <font color="orange">*</font>:</td><td colspan="2" align="right"><input type="text"name="namepic"/></td>
  </TR>
  
   <TR>
   <td colspan="3">Phone <font color="orange">*</font>:</td><td colspan="2" align="right"><input type="text" name="phone"/></td>
  </TR>
   <TR>
   <td colspan="3">Mobile:</td><td colspan="2" align="right"><input type="text" name="mobile"/></td>
  </TR>
  
   <TR>
   <td colspan="3">Fax:</td><td colspan="2" align="right"><input type="text" name="fax"/></td>
  </TR>
  
  <TR>
    <th colspan="5"></th>
  </TR>
  
  <TR>
    <td colspan="5" align="center"><input type="submit" name="proformabt" value="Send"/></td>
    <td colspan="5"><input type="hidden" name="ladate" value="<?php $today = date("D M j G:i:s T Y"); ?>"/></td>
    <td colspan="5"><input type="hidden" name="distinguish" value="<?php $distinguish++; ?>"/></td>
  </TR>
  
  <TR>
    <th colspan="5"></th>
  </TR>
     
</table>
</form>
</div>
<?php
require_once('Includes/footer.inc.php');
?>

Recommended Answers

All 5 Replies

i would suggest u to first check the values whether u r getting any values by echoinh every $_POST......
then i could help u a bit....
it will be probemistic to debug the code until u tell me the error by following these steps......
waiting for ur reply to proceed further.....

Member Avatar for begueradj

of course, when I echo the posted values it succeeds but it is the case not insertion quereies :(

Hi

$summerdraft=htmlentities(stripslashes($_POST));

i think the above line should be as below

$summerdraft=htmlentities(stripslashes($_POST));

try to print_r($_POST);
and

//try to change && into and
if(!empty($_POST['vesselname'])&&!empty($_POST['gt']).....
Member Avatar for begueradj

try to print_r($_POST);
and

//try to change && into and
if(!empty($_POST['vesselname'])&&!empty($_POST['gt']).....

I have resolved the problem:
the problem was that I have 2 fields in my tables that are keywords in SQL "FROM" and "TO"
so, i just renamed the fields in question

Thank you all, programmers
Begueradj, Algeria

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.