我试图通过会话从另一个页面获取随机id的值,但是在插入数据库时它不会插入到数据库中。它是零,这是代码:
Stud.php
<?php
session_start();
$seed = str_split('abcdefghijklmnopqrstuvwxyz1234567890');
$rand = array_rand($seed, 7);
$convert = array_map(function($n){
global $seed;
return $seed[$n];
},$rand);
$var = implode('',$convert);
echo $var;
//echo "<blink>Your Complaint is is:".$var."</blink>";
// $_SESSION['varname'] = $var;
// unset($comment);
?>
Insert.php
<?php
session_start();
include 'library/dbconnect.php';
$_SESSION['varname'] = $var;
$var_value = $_SESSION['varname'];$name=$_POST['Studname'];
$district=$_POST['district'];
$school_name=$_POST['School_name'];
$standard=$_POST['std'];
$division=$_POST['Division'];
$complaint=$_POST['Complaint'];
$entryDate=$_POST['date'];
$dateEntry=explode('-',$entryDate);
$date1=$dateEntry[2]."-".$dateEntry[1]."-".$dateEntry[0];
echo $name."<br />".$district."<br />".$date1."<br />";
$query2="INSERT INTO `Complaint_register`(`complain_Id`,`entrydate`, `studname`,
`District`, `School_name`, `Standard`, `Division`, `Complaint`, `status`) VALUES
('$var_value','$date1','$name','$district','$school_name','$standard',
'$division','$complaint',1)";
$result2=mysql_query($query2)or die(mysql_error());
$query3="SELECT * FROM Complaint_register";
$result3=mysql_query($query3);
$num=mysql_numrows($result3);
if($result2)
{
$coment= $num.' Complaint Successfully Registered';
header("Location:stud.php");
}
?>
答案 0 :(得分:0)
检查类型:抱怨_Id将其更改为varchar(1024)