putting PHP inside a HTML page.
Hello,
As far as I know I can add PHP inside a HTML page, all I need to do is open <?php and close ?> when I am finished. But now I am adding some php code to a .html page to upload an image to the database and for some strange reason as soon as the server finds a > (not a ?>) then it thinks the php code is finished and stops executing. Please find an extract of the code bellow:
I've uploaded the page on glcalcados.com.br/labs/oportunidades.html and you can see the code breaks on ($imagem_size > 0) as if the > made the server think that is the end of the php code... could someone please help?
Thanks
<body>
<!-- bellow is the code to upload the cadidates image -->
<?php
require_once('fotoappvars.php');
require_once('connectvars.php');
if (isset($_POST['submit'])) {
// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// Grab the descricao data from the POST
$imagem = mysqli_real_escape_string($dbc, trim($_FILES['foto']['name']));
$imagem_type = $_FILES['foto']['type'];
$imagem_size = $_FILES['foto']['size'];
// Check the CAPTCHA pass-phrase for verification
if (!empty($imagem)) {
if ((($imagem_type == 'image/gif') || ($imagem_type == 'image/jpeg') || ($imagem_type == 'image/pjpeg') || ($imagem_type == 'image/png')) && ($imagem_size > 0) && ($imagem_size <= GW_MAXFILESIZE)) { if ($_FILES['imagem']['error'] == 0) { // Move the file to the target upload folder
$target = GW_UPLOADPATH . $imagem;
if (move_uploaded_file($_FILES['foto']['tmp_name'], $target)) {
// Write the data to the database
$query = "INSERT INTO fotos(foto) VALUES ('$imagem')";
mysqli_query($dbc, $query);
// Clear the score data to clear the form
$imagem = "";
mysqli_close($dbc);
}
else {
echo '<p class="error">Houve um problema e a sua foto nao foi enviada, favor nos contatar</p>';
}
} } else { echo '<p class="error">A imagem deve ter como extensao GIF, JPEG, ou PNG e nao ser mais pesada do que ' . (PROMOCOES_GW_MAXFILESIZE / 1024) . ' KB in size. Contate-nos para maiores informacoes</p>'; }
// Try to delete the temporary screen shot image file
@unlink($_FILES['imagem']['tmp_name']);
}
else {
echo '<p class="error">Por favor preencha todos os campos</p>';
}
}
?>
|