Hack Forums
[PHP] [help] php & Facebook likes - need help creating new php page from template on submit - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] [help] php & Facebook likes - need help creating new php page from template on submit (/showthread.php?tid=2008182)



[help] php & Facebook likes - need help creating new php page from template on submit - tommaydp - Dec 13, 2011

Hi everyone, I'm creating a website and now I want it so when I add content (which I've allowed to do via a simple form), I want the website to create a personal like button for this piece of content, the content will have its own page, however it will be on a page extension such as /index.php?con=1 . Now this all works but the problem I have is when I click "like" it doesn't show up the preview of the content its liking. It just says I've liked url.com/index.php?con=1 . I tried to add open graph tags into the <head> of the page (like stated on the face books developers page for the like button) but because their all under the index.php webpage I'm not sure how I can add the personal preview for each piece of content. So my question is how do I do this? or is there a different way I can do this? like automatically creating a new page from a template every time content is added? or something like that? any suggestions would be greatly appreciated.

Thanks in Advance,
tommaydp


* - lattlay - Dec 14, 2011

"like automatically creating a new page from a template every time content is added" <-- this is how I did it. I have a site where each snippet of content on the homepage has its own like button leading to the content's page.
Here is the relevant line I used:
$filepathenc = "http%3A%2F%2Fmysite%2Fsubmissions%2F".$date[0]."%2F".$date[1]."%2F". $title; ?>
<div class="fb-like" data-href="<?php echo($filepathenc); ?>" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false"></div>

Notice I created directories organized by year and month for the content (so something like: http://mysite.com/content/2011/12/name.php)(btw, %3A = : and %2F = /).
Good Luck!


* - tommaydp - Dec 14, 2011

okay thanks, but how would i create a new page from a template every time content is added? (so every time a form is submitted) and how could I make sure that new page is saved to the directory /content/$id where id is the id of the content created (the id is auto incremented in mysql). Thanks in advance, Tommaydp

doesn't matter anymore I found out how to do add like buttons dynamically rather than creating a new page for each piece of content!


* - UnBoRn_HaCkEr - Dec 15, 2011

<form action="index.php" method="POST"
Username: <br><input type="text" name="user"/><br/>
Password: <br><input type="text" name="pass"/><br/>
<input type="" value="Submit">

</form>

</body>
</html>