i have a form to send to table. there is two drop down list. first has information about job of current user that logged in and second one fetch all usernames of users. a field for date a field for price and a field for comment. so my code is here:
this code get all information. submit.action.php
<form name="form5" method="post" action="send_action.php" >
<div dir="rtl">
<?php
$db_host = 'localhost';
$db_name= 'site';
$db_table= 'job_list';
$db_user = 'root';
$db_pass = '';
$user=$fgmembersite->UserNameOfUser();
$con = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");
$selected=mysql_select_db($db_name, $con) or die("خطا در انتخاب پايگاه داده");
mysql_query("SET CHARACTER SET utf8");
$dbresult=mysql_query("SELECT job_list.job_id,
job_list.job_name,
tablesite.username
FROM $db_table
INNER JOIN relation
on job_list.job_id=relation.job_id
INNER JOIN tablesite
on relation.user_id=tablesite.id_user AND tablesite.username='$user'",$con);
echo'* خدمتی که ارائه داده اید: ','<br/>';
echo '<select name="job" dir="rtl">';
while($amch=mysql_fetch_assoc($dbresult))
{
echo '<option value="'.$amch['job_id'].'">'.$amch['job_name'].'</option>';
}
echo '</select>'; ?><br/>
</div>
<!--************************************************************** -->
<div dir="rtl">
<?php
$db_host = 'localhost';
$db_name= 'site';
$db_table2= 'tablesite';
$db_user = 'root';
$db_pass = '';
$con2 = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");
$selected=mysql_select_db($db_name, $con2) or die("خطا در انتخاب پايگاه داده");
mysql_query("SET CHARACTER SET utf8");
$dbresult=mysql_query("SELECT *
FROM $db_table2",$con2);
echo'* نام کاربری که به او خدمت داده اید: ','<br/>';
echo '<select name="users" dir="rtl">';
while($amch=mysql_fetch_assoc($dbresult))
{
echo '<option value="'.$amch['id_user'].'">'.$amch['username'].'</option>';
}
echo '</select>'; ?><br/>
<label for='date' >* تاریخ عملیات:</label><br/>
<input type='text' name='date' id='date' value='' maxlength="11" placeholder="1394/1/1" /><br/>
<label for='price' >* هزینه کار:</label><br/>
<input type='text' dir="rtl" name='price' id='price' value='' maxlength="50" placeholder="54000"/><br/>
<label for='textaria' >توضیحات:</label><br/>
<textarea name="textaria" cols="" rows=""></textarea><br/>
<input name="submit" type="submit" value="ثبت عملیات" />
</div>
</form>
</span>
</div>
and in this page we send information to database but nothing sends!:
<?php
require_once("./include/membersite_config.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ارسال عملیات</title>
</head>
<body>
<?php
$id=$fgmembersite->UserID();
echo "$id"; ?>
<?php
$db_host = 'localhost';
$db_name= 'site';
$db_table= 'action';
$db_user = 'root';
$db_pass = '';
$con = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");
mysql_query("SET NAMES 'utf8'", $con);
mysql_query("SET CHARACTER SET 'utf8'", $con);
mysql_query("SET character_set_connection = 'utf8'", $con);
$selected=mysql_select_db($db_name, $con) or die("خطا در انتخاب پايگاه داده");
$ins = "INSERT INTO $db_table
(service_provider_id,customer_id,date,price,job_id,service_provider_comment)
VALUES ('$id',
'" . mysql_escape_string($_POST['users']) . "',
'" . mysql_escape_string($_POST['date']) . "',
'" . mysql_escape_string($_POST['price']) . "',
'" . mysql_escape_string($_POST['job']) . "',
'" . mysql_escape_string($_POST['textaria']) . "')";
$saved=mysql_query($ins );
mysql_close($con);
?>
</body>
</html>
note: above code give all value of dropdown list and text boxes and textarea and should send them to databasetable.
note: fg_membersite included by:
function UserID()
{
return isset($_SESSION['user_id'])?$_SESSION['user_id']:'';
}
my table is as this:
job_id int(11)
service_provider_id int(10)
customer_id int(10)
date int(50)
price int(255)
vote varchar(255)
service_provider_comment varchar(255)
customer_comment varchar(255)