Jump to content

Recommended Posts

I am having a problem with a free comment script I sourced here http://www.zimmertech.com/tutorials/php/25/comment-form-script-tutorial.php that I have implemented into my page here http://www.twowheelmotive.com

I havent changed any of the PHP from the original script just the .css elements of it however when you submit the comment it takes you to the confirmation page but then continues to refresh that page instead of taking you back to the previous.

I have been searching everywhere for the solution to make the refresh back to and cant find out a solution. I can not just enter the url because the script is called from multiple pages.

Here is the submit comment php which I belive is giving me the problem.

 
<?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='$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. ";
}

?>

As I understand this is the line that is calling for the refresh and getting passed the info for which page the comment was sent from thru the $tuturl variable however, I doesn't seem to be working.

echo "<meta http-equiv='refresh' content='2;URL=$tuturl'>";

Any help would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/280011-php-form-submit-redirect-problem/
Share on other sites

do

print_r($_POST); 

to verify that your $tuturl is correct.

 

 

I am having a problem with a free comment script I sourced here http://www.zimmertech.com/tutorials/php/25/comment-form-script-tutorial.php that I have implemented into my page here http://www.twowheelmotive.com

I havent changed any of the PHP from the original script just the .css elements of it however when you submit the comment it takes you to the confirmation page but then continues to refresh that page instead of taking you back to the previous.

I have been searching everywhere for the solution to make the refresh back to and cant find out a solution. I can not just enter the url because the script is called from multiple pages.

Here is the submit comment php which I belive is giving me the problem.

 
<?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='$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. ";
}

?>

As I understand this is the line that is calling for the refresh and getting passed the info for which page the comment was sent from thru the $tuturl variable however, I doesn't seem to be working.

echo "<meta http-equiv='refresh' content='2;URL=$tuturl'>";

Any help would be greatly appreciated!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.