before that, let me show you your code, with a change and ask you a question
The code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
var doRedirect = function(location, message, type) {
var msgClass = ''
if (type && type == 'success') {
msgClass = 'infobox';
} else if (type && type == 'error') {
msgClass = 'errorbox';
}
$('#msg').html(message).addClass(msgClass).show();
setTimeout(function () {
window.location.href = location;
}, 3000);
};
$('#msg').ready(function () {
doRedirect('index.php', 'Thanks for registering', 'success');
});
</script>
<body>
<div id="msg" class = "hide"></div>
</body>
</html>
The question:
Can I call the function from inside the div? If I can do that the problem is solved.
The code you asked:
<?php
include "lib/configuration.php";
include "language/frontend/portuguese.php";
if (isset($_SESSION['logedin'])) {
if ($_POST) {
$comp_cat = $_POST['category'];
$comp_name = $_POST['company'];
$comp_link = $_POST['link'];
$comp_desc = $_POST['description'];
$comp_addr = $_POST['address'];
$comp_county = $_POST['county'];
$comp_city = $_POST['city'];
$comp_state = $_POST['state'];
$comp_country = $_POST['country'];
$comp_phone = $_POST['phone'];
$comp_fax = $_POST['fax'];
$comp_email = $_POST['email'];
$comp_duration = $_POST['duration'];
$comp_date = date("Y-m-d");
$comp_logo = $_FILES['file']['name'];
$ext = substr($comp_logo, strpos($comp_logo,'.'), strlen($comp_logo)-1);
if(!in_array($ext, $allowed_filetypes)) {
$msg = "";
$msg = $addlinkerror['filetype'] . "</br>";
}
if(filesize($_FILES['file']['tmp_name']) > $max_filesize) {
$msg .= $addlinkerror['filesize'] . "</br>";
}
if(!is_writable($upload_path)){
$msg .= $addlinkerror['writabledir'];
}
if ($msg <> "") {
echo "<div class = 'errorbox'>" . $msg . "</div>";
}
if(move_uploaded_file($_FILES['file']['tmp_name'],$upload_path . $comp_logo)) {
$link = mysqli_connect($host, $user, $pass, $db);
/* check connection */
if (mysqli_connect_errno()) {
echo "<div class = 'errorbox'>" . $error['dbconnection'] . "</div>";
}
$query = "INSERT INTO links (comp_cat, comp_name, comp_link, comp_desc, comp_addr, comp_county, comp_city, comp_state, comp_country, comp_phone, comp_fax, comp_email, comp_duration, comp_date, comp_logo) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt = mysqli_prepare($link, $query);
mysqli_stmt_bind_param($stmt, "issssssssssssss", $comp_cat, $comp_name, $comp_link, $comp_desc, $comp_addr, $comp_county, $comp_city, $comp_state, $comp_country, $comp_phone, $comp_fax, $comp_email, $comp_duration, $comp_date, $comp_logo);
/* Execute the statement */
mysqli_stmt_execute($stmt);
if (mysqli_stmt_errno($stmt)) {
echo "<div class = 'errorbox'>" . $addlinkerror['upload'] . "</div>";
} else {
echo "<div class = 'infobox'>" . $addlinkinfo['uploaded'] . "</div>";
}
/* close statement */
mysqli_stmt_close($stmt);
/* close connection */
mysqli_close($link);
}
} else {
include "templates/frontend/header.tpl";
include "templates/frontend/loginspace.tpl";
include "templates/frontend/registerlogin.tpl";
include "templates/frontend/searchspace.tpl";
include "templates/frontend/search.tpl";
include "templates/frontend/hmenuspace.tpl";
include "templates/frontend/menubar.tpl";
include "templates/frontend/leftspace.tpl";
include "templates/frontend/leftside.tpl";
include "templates/frontend/contentspace.tpl";
if (isset($_SESSION['logedin'])) {
include "templates/frontend/addlink1.tpl";
} else {
$msg = $addlinkerror['login'];
$page = '../../index.php';
header("Location: templates/frontend/error.php?msg=$msg&page=$page");
}
include "templates/frontend/rightspace.tpl";
include "templates/frontend/rightside.tpl";
include "templates/frontend/footerspace.tpl";
include "templates/frontend/footerdiv.tpl";
include "templates/frontend/footer.tpl";
}
?>