How to Tweet your Knol Updates (Page 5)

A Tutorial

Wouldn't it be super, if after you update a knol article, you could tweet your followers about it? Well now you can.


Written 2010 by Will Johnson Jr, you can email me at
or post your comments for public view far below.
Creative Commons Attribution 3.0 License

<-- Back to How to Tweet your Knol Updates (Page 4)
--> Forward to How to Tweet your Knol Updates (Page 6)

So last we left our intrepid coding hero, he was standing in a field of wilted and rotting flowers, as unbeknown to him a meteor was hurtling at 20,000 feet per minute directly at his head.  Will he be saved?  Let's continue with our adventure and see.

Ok the next thing I did, is I contacted that programmer who wrote that recursive password code, had him come by, and then beat him.  Then I threw it out and started fresh.  He got hired by Microsoft.

Anyway.  Now what we're going to do is use two php pages.  One to simply grab the URL referrer and the password, and then pass that in a form, using the post method, to the second which will validate the password and continue the rest of the script.

So here is the code for the login form:
<HTML><title>Login Page</title>

<?php $ref_url = getenv("HTTP_REFERER");
echo "Referring URL: ".$ref_url; ?><br><br>
<form name="form" method="post" action="validatepass.php" />
<input type="password" name="txtPassword" />
<input type="hidden" name="ref_url" value=<?php echo $ref_url; ?>" />
<input type="submit" />

You can remove that bit about echoing the Referring URL once you know it all works.

And here is the code for the validation form:

<HTML><Title>Hello Knolians!</title>
// Define your password
$password = "goober";
$storedpass = $_POST['txtPassword'];
$ref_url = $_POST['ref_url'];
if ($storedpass != $password) {
echo "fail";
else {
echo "pass"; ?>
<p>This is the protected page. Your private content goes here.</p>
<?php echo "Your password was: ".$storedpass;?><br>
<?php echo "The referring URL was: ".$ref_url;

Here I'm just echoing the password and referring URL when the password matches, so that you can tell that it can tell the difference between a fail and a pass.  Try it out.  Use the password goober and then another time don't and see for yourself that it actually works, and still knows that it originally came from Knol even though you're now two pages deep!  And give me a job! Or at least buy me a sandwich, I'm a starving artist here!

Click the birdy to test the result so far.

<-- Back to How to Tweet your Knol Updates (Page 4)
--> Forward to How to Tweet your Knol Updates (Page 6)