Jump to content
xisto Community

Making A Dynamic Page On Blogspot Using an external server to make your pages hosted on blogspot dynamic

Recommended Posts

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:




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

<?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 Xisto dot net.


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

<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:

<div id="links></div>

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

<?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."\";";//writefwrite ($quotefile, $msg);//closeflock ($quotefile, LOCK_UN);fclose ($quotefile);header("location: [i]enter your page address here. don't forget the http://[/i]");?>'>http://[/i]");?>

Save as a php file.

Next use the text editor again to create a file:

// JavaScript Documentvar 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:

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

Add this to the body:

<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:

<script language="javascript" type="text/javascript">//print quotesvar 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.

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

MH is right. Might be as simple as wrapping the $_POST variables in a trim() and stripslashes().Possibly an htmlentities(), too?

Share this post

Link to post
Share on other sites

thanks for the info!but can anyone list out if there are any dangers involvedthe part that involves 'yourusername.secretpass@blogger.com'will anyone be able to see it with the code u wrote?

Share this post

Link to post
Share on other sites

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.

Edited by Sprnknwn (see edit history)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.