mysql - sending variables to table PHP SQL -
im trying send variables table error $title , $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 $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>
i solved problem, myself.
we should use of 2 pages:
- sending input boxes via form page.
insert input boxes via these codes:
$ins="insert $db_table (user_id,title,body) values('$user_id','" .
mysql_escape_string($_post['title']) . "','" .
mysql_escape_string($_post['body']) . "')";
Comments
Post a Comment