我是PHP的新手。这是我的代码:
$con_cursuri=mysqli_connect("localhost","root","","proiect");
$date = date('Y-m-d H:i:s');
$usid=$_SESSION['id'];
$result = mysqli_query($con_cursuri,"SELECT * FROM cursuri INNER JOIN subiecte ON idSubiecte= Subiecte_idSubiecte");
while($row = mysqli_fetch_array($result))
{
echo "<table border=1><form action='cursuri.php' method='POST'> <br><tr><td width=290px ><a href=".$row['link'].">".$row['nume_curs']."</a></td><td width=290px>".$row['descriere_curs']."</td></tr>".$row['nume_subiect']."<td width=290px><input type=hidden name=id value=".$row['idCursuri']."><input type=submit name=submit value='Inrolare curs!'></form></td>
<br>";
}
$submit=$_POST['submit'];
$id_curs=$_POST['id'];
if($submit)
{
$inrolare_curs = mysqli_query($con_cursuri,"INSERT INTO inrolare_curs VALUES('', '$usid', '$date', '', '$id_curs')") ;
}
有什么建议吗?
P.S。:昨天,该页面有效。我安装了xampp,但结果是一样的。
答案 0 :(得分:1)
检查以下内容:
<?php
位于脚本的开头.php
(默认情况下)<?php echo "hello world"; ?>
另请参阅此答案:Apache is downloading php files instead of displaying them
答案 1 :(得分:0)
我认为你没有使用过php的开始和结束标记,即
<?php
//your code goes here
?>
相反,您使用的是短标签,并且未按@john conde
的回答启用