0

I am new to PHP. This is my code:

$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')") ;  
}

Any sugestions?

P.S.: yesterday, the page worked. I reinstalled xampp, but the result is the same.

2 Answers2

1

check the followings:

  • <?php is at the start of the script
  • the file extension should be .php (by default)
  • check if php is enabled in your apache configurations: this and this
  • use a sample script to check if php is working: <?php echo "hello world"; ?>
  • install another tool like xampp (example: ampps)

Also take a look to this answer: Apache is downloading php files instead of displaying them

Community
  • 1
  • 1
ProGM
  • 6,949
  • 4
  • 33
  • 52
  • 1
    `the file extension must be .php`. only in default setting – Marcin Orlowski Jan 04 '14 at 13:54
  • I am using , The extension is .php, I tried to echo "hello world" and nothing happend. The page is blank – IronicBeatz Jan 04 '14 at 13:55
  • How are you accessing to the web page? Which URL are you using? – ProGM Jan 04 '14 at 13:57
  • h t t p : // localhost – IronicBeatz Jan 04 '14 at 13:58
  • @user3160374 check if there is such .htaccess file in your htdocs directory or take a look to the default extension of php. Check this answer: http://stackoverflow.com/questions/18422140/apache-is-downloading-php-files-instead-of-displaying-them – ProGM Jan 04 '14 at 14:02
  • Try with another application, like [ampps](http://www.ampps.com/), and make some test. Make some comparison on the configuration files – ProGM Jan 04 '14 at 14:25
  • try this, in command prompt type `path\to\xampp\php.exe` `path\to\your\file` if this works then php module isn't loaded in your apache conf which is srange. – Jigar Jan 08 '14 at 19:21
0

I think you have not used the start and end tag of php i.e.,

<?php
//your code goes here
?>

Rather you are using the short tags and it is not enabled as answered by @john conde

Sam
  • 1,623
  • 1
  • 19
  • 31