sending information to database SQL PHP

Wednesday, November 4, 2015

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





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'* خدمتی که ارائه داده اید: ','
';
echo '';

while($amch=mysql_fetch_assoc($dbresult))
{
echo ''.$amch['job_name'].'';
}
echo ''; ?>

<!--************************************************************** -->

';
echo '';

while($amch=mysql_fetch_assoc($dbresult))
{
echo ''.$amch['username'].'';
}
echo ''; ?>



* تاریخ عملیات:

* هزینه کار:


توضیحات:



</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']:'';
}

0 comments:

Post a Comment