I had this script originally placed in a linked file favorite.php.

When the user clicked add to favorites on a users profile from the page profile.php it would link to favorite.php and run the sql query.

Is there a way i can now add this script to the profile.php page so that it echos out the message on the same page (profile.php).

When i just copy and paste the script it clears the whole content of the profile.php page and says user not found.

Can someone please show me what i'd need to do. thanks

```
<?php

require_once('includes/session.php');
require_once('includes/functions.php');
require('includes/_config/connection.php');

session_start();

    confirm_logged_in();

    if (isset ($_GET['to'])) {
    $user_to_id = $_GET['to'];

}

if (!isset($_GET['to']))
    exit('No user specified.');

$user_id = $_GET['to'];

$result = mysql_query("INSERT INTO ptb_favorites (user_id, favorite_id) VALUES (".$_SESSION['user_id'].", ".$user_to_id.")") 
or die(mysql_error()); 

echo "<div class=\"infobox-profile\"><strong>This is your profile</strong> - to edit now <a href=\"account_settings.php\">click here</a></div>";

?>

```

p.s i would add the code for profile.php but only if it's essential for you to know how that page is laid out because theres too much code on that page.