Reputation: 717
im trying to send my variables to table but i get error for $title and $body:
Undefined variable: title in C:\wamp\www\source\pishnahad.php on line 237
Notice: Undefined variable: body in C:\wamp\www\source\pishnahad.php on line 237
<div class='container' dir="rtl" >
<label for='name'>نام: </label>
<input type='text' name='name' id='name' value='<?= $fgmembersite->UserFullName() ?>' maxlength="50" disabled="disabled"/><br/>
</div>
<div class='container' dir="rtl" >
<label for='email'>ایمیل: </label>
<input type='text' name='email' id='email' value='<?= $fgmembersite->UserEmail() ?>' disabled="disabled"/><br/>
</div>
<form name="form2" method="post" action="submit_shekayat" accept-charset='UTF-8'>
<div class='container' dir="rtl" >
<label for='title'>موضوع: </label>
<input type='text' name='title' id='title'/><br/>
</div>
<div class='container' dir="rtl" >
<label for='body'>توضیحات: </label> <br />
<textarea name="body" id="body" cols="" rows="" style="width:300 ;height:300"></textarea>
</div>
<?php
$user_id =$fgmembersite->UserID();
$db_host = 'localhost';
$db_name= 'site';
$db_table= 'shekayat';
$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("خطا در انتخاب پايگاه داده");
mysql_query("SET CHARACTER SET utf8");
$ins="INSERT INTO $db_table (user_id,title,body) VALUES('$user_id','$title','$body')";
$saved=mysql_query($ins );
mysql_close($con);
?>
<div class='container'>
<input type='submit' name='Submit' value='ارسال اطلاعات' />
</div>
Upvotes: 1
Views: 47
Reputation: 717
I solved my problem, myself.
We should use of two pages:
Insert input boxes via these codes:
$ins="INSERT INTO $db_table (user_id,title,body) VALUES('$user_id','" .
mysql_escape_string($_POST['title']) . "','" .
mysql_escape_string($_POST['body']) . "')";
Upvotes: 1
Reputation: 349
You have the
$user_id = $fgmembersite->UserID();
But where
$title
and
$body
come from ? If you want to assign $body a value of the textarea with the ID body
you have to use JS Ajax call for example or simply hardcoding it (which is not recommended).
Upvotes: 0