1

i have a profile page which uses php includes to get reviews.php and posts.php displayed on the page.

the page reviews.php has a form and i am trying to get this form to submit/use the action php server self but when i do this for some reason it ignores the mysql query on the page reviews.php and instead of inserting it into the table ptb_reviews it inserts it into ptb_posts. so the problem here is its carrying out the query on posts.php and i dont know why this is happening, can someone please help me?

here's the reviews.php page

<?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() ?>

1 Answer 1

1

To submit a form to the current page, which is what it seems you are trying to do, just specify an empty action:

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

The form will now submit to the same URL as the current page is.

Sign up to request clarification or add additional context in comments.

1 Comment

this still doesnt solve my problem, is there a way i can specify an area on the page for the form action to point to?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.