1

我有一个配置文件页面,它使用 php 包含来获取页面上显示的 reviews.php 和 posts.php。

页面reviews.php有一个表单,我试图让这个表单提交/使用操作php服务器自我但是当我出于某种原因这样做时,它会忽略页面reviews.php上的mysql查询,而不是将其插入它将表 ptb_reviews 插入到 ptb_posts 中。所以这里的问题是它在posts.php上执行查询,我不知道为什么会这样,有人可以帮我吗?

这是reviews.php 页面

<?php ob_start(); ?>
 <?php 
// check if the review form has been sent
if(isset($_POST['review_content']))
{
    $content = $_POST['review_content'];
        //We remove slashes depending on the configuration
        if(get_magic_quotes_gpc())
        {
                $content = stripslashes($content);
        }
        //We check if all the fields are filled
        if($_POST['review_content']!='')
        {


            {
            $sql = "INSERT INTO ptb_reviews (id, from_user_id, to_user_id, content) VALUES (NULL, '".$_SESSION['user_id']."', '".$profile_id."', '".$content."');";
            mysql_query($sql, $connection);

            $_SESSION['message']="<div class=\"infobox-wallpost\"><strong>Thank You</strong> - Your review has been sent to the Escort and is awaiting approval.</div><div class=\"infobox-close4\"></div>"; 
header("Location: {$_SERVER['HTTP_REFERER']}");


        } }
}

?> 
<div class="reviewcontent">
 <?php
$profile_bits = get_profile_bits();
while ($profile = mysql_fetch_array($profile_bits)) { ?>  
<?php if ($user['account_type'] == "Escort"){
?>
<?php
 $days = $reviews['date_added'];

function days_from_date2($days) {


       $age = date_diff(date_create($days), date_create('now'))->d;  
       return $age;
}

?>

<div class="reviewcontent1">
<?php
    $reviews_set = get_reviews();
    ?>
    <br/>
    <h3><span class="underline"><?php echo "".$profile['display_name'].""; ?>'s Latest Reviews</span></h3>
    <br/> 


    <?php
    if(mysql_num_rows($reviews_set) > 0) {
        while ($reviews = mysql_fetch_array($reviews_set)) {
            $age = days_from_date($reviews['date_added']);
            ?>
            <div class="review_box" id="reviewcase">
             <div class="review-content2">
             <?php echo "{$reviews['content']}"; ?>
             </div>
             <div class="message_pic2">
             <?php echo "<a href=\"profile.php?id={$reviews['from_user_id']}\"><img width=\"50px\" height=\"50px\"  src=\"data/photos/{$reviews['from_user_id']}/_default.jpg\"></a>";?>

             </div>

             <div class="reviews_footer2">
             <?php echo "Posted by {$reviews['display_name']}"; ?>&nbsp;<?
        $datetime1 = new DateTime();
        $datetime2 = new DateTime ($reviews['date_added']);
        $interval = $datetime1->diff($datetime2);
        $mdhms = explode('-',$interval->format('%m-%d-%H-%i-%s'));

$labels = Array(' months', ' days', ' hours', ' minutes', ' seconds');
$i = 0;
foreach($mdhms as $t){
  if($t > 0) break;
  $i+=1;
}
        echo "about ".$t.$labels[$i]." ago"; ?>





          </div>


             </div>

             <?
$account_type = account_type();
while ($acctype = mysql_fetch_array($account_type)) 

 if ($acctype['account_type'] == 'Client')  { 

 echo "
 <div class=\"add_review_text\">add a review now</div>";

    } ?>




             <?
        }

        }else{



    if (!logged_in()) {


echo "
<div class=\"review_box_example\"><div class=\"example_review_pic\"><img width=50px height= 50px src=\"data/photos/0/post.jpg\"/>
</div><div class=\"example_review_text2\">{$profile['display_name']}, you were fantastic!<br/>I can not wait to meet with you again, you were very professional and made me feel very comfortable.<br/><br/>John x</div><div class=\"example_review_pic2\"></div></div><div class=\"example_box_container2\"><div class=\"review_example_arrow2\"></div><div class=\"review_example_box2\"></div><div class=\"review_example_text2\"><strong>Here's an Example</strong></div></div>";


    }else{



    if (logged_in()) {


echo "
<div class=\"review_box_example\"><div class=\"example_review_pic\"><img width=50px height= 50px src=\"data/photos/0/post.jpg\"/>
</div><div class=\"example_review_text2\">{$profile['display_name']}, you were fantastic!<br/>I can not wait to meet with you again, you were very professional and made me feel very comfortable.<br/><br/>John x</div><div class=\"example_review_pic2\"></div></div><div class=\"example_box_container2\"><div class=\"review_example_arrow2\"></div><div class=\"review_example_box2\"></div><div class=\"review_example_text2\"><strong>Here's an Example</strong></div></div>"; ?>

<?
$account_type = account_type();
while ($acctype = mysql_fetch_array($account_type)) 

 if ($acctype['account_type'] == 'Client')  { 

 echo "
 <div class=\"add_review_text\">add a review now</div>";

    } ?>

    <?


    $account_type = account_type();

     if ($acctype['account_type'] == 'Escort') {
echo "<div class=\"infobox-noreviews\"><i>{$profile['display_name']} doesn't currently have any posts on his wall.<br/>Why not post a comment to his wall now.</i></div>";


 }


        }

?>



<?

}  }
?>
<?php

{?>      











<? } } } ?>

</div>
</div>







<div class="reviewcontent2">

i love me 
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<textarea name="review_content" id="review_content" maxlength="180" cols="33" rows="5" class="review_input_box2" style="resize: none;"></textarea>
<input name="add_review" type="image" src="http://www.playtimeboys.com/assets/img/icons/save-edit.png" BORDER="0" ALT="SUBMIT!"class="review_submit4" /></form>

</div>

<script>
    $(".reviewcontent2").hide();

    $('.add_review_text').click(function () {
        if ($('.reviewcontent1').is(":visible")) {
             $(".reviewcontent1").fadeOut(300);
             $('.reviewcontent2').delay(400).fadeIn(300);

        } else if ($('.reviewcontent2').is(":visible")) {
            $('.reviewcontent2').fadeOut(300);
            $('.reviewcontent1').delay(400).fadeIn(300);


        }
    });
</script>
<?php ob_end_flush() ?>
4

1 回答 1

1

要将表单提交到当前页面,这似乎是您正在尝试执行的操作,只需指定一个空操作:

<form action="" method="post">

该表单现在将提交到与当前页面相同的 URL。

于 2013-04-02T20:37:01.393 回答