Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6006427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:32:15+00:00 2026-05-23T01:32:15+00:00

I’v currently developing a php facebook canvas in an IFrame. The Idea is for

  • 0

I’v currently developing a php facebook canvas in an IFrame. The Idea is for the user to upload pictures to mySql Database with the userdata supplied by Facebook from there api.

Everything goes well until I have to save the Userdata along with picture. After I pushed submit and the picture is uploaded. it reloads the page and the picture is shown, but the userdata from facebook is not inserted along with it. I have tried lots of options here on the internet but it doesn’t care.. It will not inser the userdata along with the picture.

I have an index file which looks like this:

        <?php 
    setcookie("fag");
    session_start();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link type="text/css" rel="stylesheet" href="css/style.css" />
    <title>Facebook</title>
    <?php
    define('MyConst', TRUE);
    include_once 'ClassLibrary/User_AR.php';
    include_once 'ClassLibrary/FacebookApi.php';
    include_once 'ClassLibrary/ImageUpload.php';
    $sr = new User_AR();
    $fb = new FacebookApi();
    $iu = new ImageUpload();
                $info = $fb->getUserInfo();
                $_COOKIE["fag"] = $info;
                    foreach ($info as $key => $v )
            {
            switch ($key)
            {
            case "ID":
                echo $v;
                break;
            case "Name":

                echo $v;
                break;
            case "Email":
                echo    $v;
                break;
            case "Img":
                echo $v;

                break;
            }
            }
    ?>

    </head>

    <body>

    <?php 

             if (isset($_POST["sendPhoto"])) {
                echo "Is Set";

                if ($sr->exists($info["ID"]) == false) {
             $iu->processForm();
                }else{
                $iu->displayForm();
                }
            }
            else
            {
                $iu->displayForm();
                echo "Is not Set";
            }
    $arr = array($sr->getAllUsers());
     for($i = 0; $i < count($arr); $i++){
    foreach ($arr[$i] as $key => $value) {
            echo "<div class=".'"'."userBox".'"'.">"."<div class=".'"'."innerBox".'"'.">
            <div class=".'"'."Title".'"'.">Navn :</div><div class=".'"'."Values".'"'.">".$value["Name"]."</div>".
            "<div class=".'"'."Dato".'"'.">Dato :</div><div class=".'"'."Values".'"'.">".date("m.d.y")."</div>".
            "<div class=".'"'."Title".'"'.">Billede :</div><div class=".'"'."img".'"'."><img alt=".'"'."BrugerBillede".'"'." height=".'"'."150".'"'." width=".'"'."150".'"'." class=".'"'."Image".'"'."src=".'"'.$value["Img"].'"'."/></div></div></div>";
         }
     }

    ?>



    </body>
    </html>

Keep in mind that this code is sandbox code and may contain odd words that is the result of a tired developer who can’t get this to work!

Anyway this is supposed to show the uploadform and let you upload the file and if you are registeret in the mysql db it wont show you the form.

Now this is the ImageUpload file which contains the code for upload picture getting the information.

function __construct()
{       
        $killer = $_COOKIE["fag"];

            foreach ($killer as $key => $v )
            {
        switch ($key)
        {
        case "ID":
            $id = $v;
            echo $id;
            break;
        case "Name":
            $name = $v;
            echo $name;
            break;
        case "Email":
            $email = $v;
            echo $email;
            break;
        case "Img":
            $img = $v;
            echo $img;
            break;
            }

        }

}

    function displayForm() {

    echo "<form action=".'"'.$this->processForm().'"'. "method=".'"'."post".'"'."enctype=".'"'."multipart/form-data".'"'.">
<div>

<input type=".'"'."hidden".'"'. "name=".'"'."MAX_FILE_SIZE".'"'."value=".'"'."100000".'"'."/>
<label for=".'"'."userfile".'"'.">Upload file:</label>
<input type=".'"'."file".'"'."name=".'"'."photo".'"'. "id=".'"'."photo".'"'."/>
<input type=".'"'."submit".'"'. "name=".'"'."sendPhoto".'"'."value=".'"'."Send Photo".'"'."/>

</div>
</form>";
    }
function processForm(){
    $se = new User_AR();
            if (isset($_FILES["photo"]) && $_FILES["photo"]["error"] == UPLOAD_ERR_OK){

                if ($_FILES["photo"]["type"] !="image/jpeg") {
                        echo "<p>Kun JPG or PNG </p>";
                        $this->bool = false;
                }
                else if(!move_uploaded_file($_FILES["photo"]["tmp_name"], "images/".basename($_FILES["photo"]["name"])))
                {
                    //echo "<p>Im sorry there was a problem uploading that photo</p>".$_FILES["photo"]["error"];
                }
                else 
                {



                $se->InsertPict($this->name,$this->email,"images/".basename($_FILES["photo"]["name"]),$this->id);           
                $this->displayThanks();         

                }

            }else{

            echo $_FILES["photo"]["error"];
            }



/*              if (isset($_FILES["photo"])&& $_FILES["photo"]["error"] == UPLOAD_ERR_OK) {
            if ($_FILES["photo"]["type"] !="image/jpeg") {
                echo "<p>Kun JPG </p>";

            }else if (!move_uploaded_file($_FILES["photo"]["tmp_name"], "images/".basename($_FILES["photo"]["name"])))
            {
                echo "<p>Im sorry there was a problem uploading that photo</p>".$_FILES["photo"]["error"];

            }else{

                }
        }else 
        {
            switch ($_FILES["photo"]["error"]) {
                case UPLOAD_ERR_INI_SIZE:
                    $message = "The photo is larger than server allows";
                    break;
                case UPLOAD_ERR_FORM_SIZE:  
                    $message = "The photo is larger  than the script allows.";
                break;
                case UPLOAD_ERR_NO_FILE:
                    $message = "No file was uploaded. Make sure you choose a file to upload.";

                default:
                    $message = "Please contact your server administrator for help";
                break;
            }
    echo "FEST          ". $killer["Name"];
        }*/
            function getitman() {


            }

    }

    function displayThanks() {
        echo "<p><img src=".'"'."images/".$_FILES["photo"]["name"].'"'." alt=".'"'."Photo".'"'."/> Thanks!</p>";
    }

    function __destruct() {

    }
}

?>

Now this is where it gets totally weird and crazy. this line of code it wont do what i tell it to do (only save the image)

$se->InsertPict($this->name,$this->email,"images/".basename($_FILES["photo"]["name"]),$this->id);

When put it this if/else construction it will only save my image NOT the userdata

function processForm(){
    $se = new User_AR();
            if (isset($_FILES["photo"]) && $_FILES["photo"]["error"] == UPLOAD_ERR_OK){

                if ($_FILES["photo"]["type"] !="image/jpeg") {
                        echo "<p>Kun JPG or PNG </p>";
                        $this->bool = false;
                }
                else if(!move_uploaded_file($_FILES["photo"]["tmp_name"], "images/".basename($_FILES["photo"]["name"])))
                {
                    //echo "<p>Im sorry there was a problem uploading that photo</p>".$_FILES["photo"]["error"];
                }
                else 
                {
                $se->InsertPict($this->name,$this->email,"images/".basename($_FILES["photo"]["name"]),$this->id);           
                $this->displayThanks();         

                }

            }else{

            echo $_FILES["photo"]["error"];
            }





}

But as soon as I put it outside of the if/else construct it saves all the information.. but not the image and does this as soon as I connect to the facebook ap/canvas page. which is not desirable (since users has to upload picture). But I am so confused and about to go stark raving mad because of this crazy code!

This is the User_AR php file:

<?php
include_once 'ClassLibrary/DbConn.php';
include_once 'ClassLibrary/FacebookApi.php';

class User_AR  {

    function getAllUsers() {
    $exp = array();
    $con = new DbConn();
    $result =  $con->command("select * FROM User");
    while (($row = mysqli_fetch_array($result))!=false) {
        $exp[] = array("ID" => $row["UserID"],"Name" => $row["UserName"],"Email" =>$row["UserEmail"],"Img" => $row["UserImg"],"FaceID" => $row["UserFaceID"]);
}
    return $exp;
    }

public  function InsertPict($Name,$Email,$Img,$ID) {
        $con = new DbConn();
        if (mysqli_num_rows($con->command("SELECT * FROM User WHERE UserFaceID =".$ID.""))== 0) {
            $res = $con->command("INSERT INTO User(UserName, UserEmail,UserImg, UserFaceID) values('$Name','$Email','$Img','$ID')");
        echo    $message = "Dit billede er nu lagt op og du deltager i konkurrencen";
        }else 
        {
        echo    $message = "Du har allerede indsendt et billede og deltager i konkurrencen";

        }

    }
    function exists($faceID) {
        $fb = new FacebookApi();
        $gg = $fb->getUserInfo();

//$game  = count_chars($_COOKIE["fag"]["Name"],3);
///     echo $game.$gg["Name"];
        $con = new DbConn();
        if (mysqli_num_rows($con->command("SELECT * FROM User WHERE UserFaceID = $faceID")) == 0) {
            $var = false;

            return $var;
        }else 
        {
            $var = true;
            return $var;
        }
    }


}

?>

I know this to work, because when I move the function “InsertPict” outside of the if/else in the ImageUpload class it works perfectly.

Since I’v been at this for aeons and maybe blind to obvious mistakes or such.. Can any of you fellow dev. help me out here before I go completely nuts and get fired for eating the keyboard. I will gladly appriciate any help.

Thanks on beforehand!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:32:16+00:00Added an answer on May 23, 2026 at 1:32 am

    I ended up rewritting the entire code and that solved the problem. Instead of using the example code given on the facebook dev. page i used the php base code files and that worked. Sorry for the inconvinience.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.