Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Making A Dynamic Page On Blogspot, Using an external server to make your pages hosted on blogspot dynamic
dyknight
post Jun 30 2006, 12:59 PM
Post #1


Newbie [Level 2]
**

Group: Members
Posts: 32
Joined: 30-June 06
Member No.: 25,862



Good morning everyone.

Have you ever wondered how to allow your visitors to edit content on your blog? Like adding a post straight off the page, adding a link, editing your profile etc. This will be extremely useful if you want your visitors to contribute to your blog besides writing comments or tagging.

1. Adding a post straight off the page.

Go to blogger.com, login, select your blog.
Go to settings -> email.

By enabling blog email, you can now add a post by simply sending an email to the address you specified. The address should look something like:

yourusername.secretpass@blogger.com

Now open up a text editor, and paste this code (note the italics):
CODE

<?php

/*******************************************
    This script sends an email to Blogger
    to post on blogspot.com
    
    Called by: form on blogspot.com
*********************************************/

    $subject = $_POST["subject"];
    $headers = $_POST["author"];
    $message = $_POST["message"]."
    
    ".$headers;
    $email = "[i]enter your blogger email here. make sure it is in the inverted commas[/i]";
    
    mail($email,$subject,$message);
    header ("location: [i]enter your blogspot address here. make sure you add http:// before the address[/i]");
    
?>


Save the above file as a php file.
Upload the php file on a server that supports php, such as trap17 dot net.

Go to blogger templates, and paste the following code (note the italics) where you want the form to appear:
CODE

<form action="[i]enter your php script URL here[/i]" method="post" name="post">
    <table>
          <tr>
              <td><label>Author</label></td>
              <td><input type="text" name="author" /></td>
          </tr>
        <tr>
              <td><label>Subject</label></td>

              <td><input type="text" name="subject" /></td>
        </tr>  
          <tr>
                <td><label>Post</label></td>
              <td><textarea name="message"></textarea></td>
        </tr>
        <tr>
            <td><input type="submit" value="Post!" /></td>

        </tr>
    </table>      
    </form>


Tada! Now your visitors can use the form to add a post. The form wil call your php script, which will send an email to blogger and redirect back to your page.

2. Changing content.

For this tutorial, I will use "Links" as an example. The script will let user add links to your 'links' section.

Go to blogger template and paste the following code to create a links section. Do not put anything inside the div:
CODE

<div id="links></div>


Now open up a text editor and paste the following (note the italics):
CODE

<?php
    
/*********************************************
    This script appends to the javascript
    links.js
    
    Called by: form on blogspot.com
    Calls: links.js    
*********************************************/

//open file
$quotefile = fopen ("links.js",a);
flock ($quotefile,LOCK_EX);

//get contents
$time = "<h3>".$_POST["time"]."<br>";
$title = $_POST["title"]."</h3>";

$quote = str_replace ("
","<br>",$_POST["quote"])."<br>";

$msg = "quotes = quotes + \"".$time.$title.$quote."\";";

//write
fwrite ($quotefile, $msg);

//close
flock ($quotefile, LOCK_UN);
fclose ($quotefile);

header("location: [i]enter your page address here. don't forget the http://[/i]");

?>


Save as a php file.
Next use the text editor again to create a file:
CODE

// JavaScript Document

var quotes = "[i]enter your formatting here. e.g. <h1>links</h1>[/i]";


Save as links.js.
Upload both files to your server.

Go to blogger template, add the following at the top of the script, within the head tag:
CODE

<script type="text/javascript" src="[i]enter the address of links.js. Make sure you have the http://[/i]">
</script>


Add this to the body:
CODE

<form action="[i]enter the address of your php script. Make sure you have the http://[/i]" method="post" name="post">
    <table>
          <tr>
              <td><label>Date/Time</label></td>

              <td><input type="text" name="time" /></td>
          </tr>
        <tr>
              <td><label>Title</label></td>
              <td><input type="text" name="title" /></td>
        </tr>  
          <tr>
                <td><label>Quote</label></td>

              <td><textarea name="quote"></textarea></td>
        </tr>
        <tr>
            <td><input type="submit" value="Add!" /></td>
        </tr>
    </table>      
    </form>


Now, go to the end of the html, and add this before closing the body tag:
CODE

<script language="javascript" type="text/javascript">
//print quotes
var printTo = document.getElementById('links');
printTo.innerHTML = quotes;
</script>


And you are done. The form will call for the php script, which will append to links.js. The html will load links.js and the variable quotes. The last script in the html will get the div "links" and write the contents of the string quotes to the innerHTML.
Go to the top of the page
 
+Quote Post
Trair
post Jul 2 2006, 04:29 AM
Post #2


Newbie [Level 1]
*

Group: Members
Posts: 18
Joined: 1-July 06
Member No.: 25,903



Very nice! I myself don't have a use for it, but I'm sure somebody does... smile.gif
Go to the top of the page
 
+Quote Post
michaelper22
post Oct 6 2006, 05:50 PM
Post #3


-=Hybrid Bus=-
*********

Group: Members
Posts: 742
Joined: 2-November 05
From: My hybrid bus (in NYC), a computer
Member No.: 13,709
Spam Patrol



That is a nice tutorial. Visitor interaction is relatively important these days. But realize that spammers can take advantage of this, since you are leaving an email form out in the open for them to use.
Go to the top of the page
 
+Quote Post
jlhaslip
post Oct 6 2006, 06:31 PM
Post #4


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 4,301
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol
myCENT:63.90



MH is right.

Might be as simple as wrapping the $_POST variables in a trim() and stripslashes().
Possibly an htmlentities(), too?
Go to the top of the page
 
+Quote Post
styfer
post Dec 12 2006, 01:17 PM
Post #5


Newbie [Level 1]
*

Group: Members
Posts: 24
Joined: 4-December 06
Member No.: 34,614



thanks for the info!
but can anyone list out if there are any dangers involved
the part that involves 'yourusername.secretpass@blogger.com'

will anyone be able to see it with the code u wrote?
Go to the top of the page
 
+Quote Post
Sprnknwn
post Dec 12 2006, 03:30 PM
Post #6


Privileged Member
*********

Group: Members
Posts: 821
Joined: 6-March 05
Member No.: 4,202



Oh, interesting. I didn´t know you could do this in a site like blogger, so pre-established. I have a blogger account there doing nothing really... maybe someday i will try this to see how it works, although I´m afraid that this will be very easy for spammers to fill your site with their messages.

This post has been edited by Sprnknwn: Dec 12 2006, 03:30 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Changing A Dynamic Ip(18)
  2. Test Your Php Pages W/o Upload/internet(57)
  3. Custom 404 Error Pages(17)
  4. Server Status(12)
  5. Css And Javascript Combined For Dynamic Layout(9)
  6. Tutorial: Installing D-shoutbox For Ipb V1.2(12)
  7. Making Winrar Archives(13)
  8. How To: Make A Simple Php Site(21)
  9. Templating System Using Php Includes(13)
  10. Making Interactive Cds With Flash(2)
  11. Dynamic Signatures - The Real Way To Go(8)
  12. Making The Popular Id Browsing For Your Site.(17)
  13. Do You Want To Use Php Code In Your Html Pages?(9)
  14. Making a java based program(3)
  15. Making A One Page Does All Website In Phph(2)
  1. Dynamic Signature - Yet Another Way To Do It(0)
  2. Creating A Resume(1)
  3. How To Create Counter-strike 1.6 Server In Console Mode(5)
  4. Making A Song In Fruity Loops Part 2(0)
  5. Making A Song In Fruity Loops Part Three(1)
  6. Ftp In Visual Basic 6.0(3)
  7. Php--> Content-only Pages(9)
  8. Simple Javascript And Password System(9)
  9. How To Make Your Own Counter Strike Source Dedicated Server!(40)
  10. How To Make An Ultimate Game List.(0)
  11. Making Calculators with PHP(4)
  12. Create Dynamic Html/php Pages Using Simple Vb.net Code(1)
  13. [aef] Most Recent Topics Listing Mod(2)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 09:51 PM