plik inc_rate.php
plik
a to plik submitcomments.php
Cytat
<?php
//Please set the following variables for your mysql database:
$db_hostname = "localhost"; //usually "localhost be default"
$db_username = ""; //your user name
$db_pass = ""; //the password for your user
$db_name = ""; //the name of the database
/*MYSQL DATABASE CONNECTION/ TRACKING FUNCTIONS
--------------------------------------*/
// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);
$tuturl = $_POST["tuturl"];
$tutid2 = $_POST["tutid2"];
$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$message = $_POST["message"];
$sendcomment = mysql_query("INSERT INTO comments SET tutorialid='$tutid2', name='[/color][color="#a52a2a"]$name', url='$url', email='$email', comment='$message', date=now()");
if($sendcomment){
//header("Location: $tuturl");
echo "<h1>Submission Successful</h1>";
echo "Your comment has been submitted. You will now be redirected back to the last page you visited. Thanks!";
echo "<meta http-equiv='refresh' content='2;URL=$tuturl'>";
} else {
echo "There was an error with the submission. ";
}
?>
//Please set the following variables for your mysql database:
$db_hostname = "localhost"; //usually "localhost be default"
$db_username = ""; //your user name
$db_pass = ""; //the password for your user
$db_name = ""; //the name of the database
/*MYSQL DATABASE CONNECTION/ TRACKING FUNCTIONS
--------------------------------------*/
// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);
$tuturl = $_POST["tuturl"];
$tutid2 = $_POST["tutid2"];
$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$message = $_POST["message"];
$sendcomment = mysql_query("INSERT INTO comments SET tutorialid='$tutid2', name='[/color][color="#a52a2a"]$name', url='$url', email='$email', comment='$message', date=now()");
if($sendcomment){
//header("Location: $tuturl");
echo "<h1>Submission Successful</h1>";
echo "Your comment has been submitted. You will now be redirected back to the last page you visited. Thanks!";
echo "<meta http-equiv='refresh' content='2;URL=$tuturl'>";
} else {
echo "There was an error with the submission. ";
}
?>
Po napisaniu komentarza przez użytkownika wyświetla się nowa strona z "Your submit......" która po kilku sekundach odświeża się i powraca do strony komentarzy, tutaj moje pytanie, czy jest jakaś możliwoś na zapisanie komentarza bez przeładowania strony, np aby wyświetlił się komunikat o zapisaniu komentarza lub komentarz został automatycznie zapisany bez ładowania strony submitcomment.php ?
Próbowałem umieścić kod z submitcomment.php w inc_rate.php, na różne sposoby ale nic mi nie wychodzi, proszę o pomoc.