Webhosting problem

I really liked my web hosting company, till about two weeks ago. Then they messed it up. They messed it up bad… I was (am) very angry. My Database is screwed up, php was upgratded to 5 from 4 without notice so some of the scripts stopped functioning, worst of all, my e-mail domain was labeled spam, therefore not being able to get or send e-mail from my main account (thank god for gmail…).

So I went ahead and created new account at new hosting company, then started to move some of the sites. (I have way too many sites is one of the probelm…) but in this process I have learned (or re-learned) some of simple (but usuful) web related stuff, following is just a note to myself:

URL Rewrite

I wanted simply have /index.php?id=000000 (where 000000 is 6 digit numbers) to show up as /archive/000000 to the users. Create .htaccess file and put this in there

RewriteEngine on
RewriteRule ^archive/([0-9][0-9][0-9][0-9][0-9][0-9])$
index.php?id=$1

Related sites: Your HTML source, Hosting company wiki

PHP 5′s post/get data

You just need to have this in the bigining of the file:

<?php import_request_variables(g, "g_"); ?>

Now all your “Get” variable like index.php?id=12234&name=5678 can be accessed as $g_id and $g_name

Very simple form validator

In form with name=”sampleform”, have action=”/result.php” method=”post” onsubmit=”return validate()”. Say in this form you have name and comments and they are both required.


<script type="text/javascript">
<!--
function validate()
{
x=document.sampleForm
yourcomment=x.comments.value
yourname=x.name.value
  if (yourname.length<1)
   {
   alert("Please enter your name")
   return false
   }
  else if (yourcomment.length<1)
   {
   alert("Please enter your comment")
   return false
   }
  else
   {
   return true
   }
}

// -->
</script>

Simple caching mechanism for php

On one of my website, I had a query to mysql everytime user comes to the page, but I knew that the data only changes once a day. Those two sites really helped me oput: devshed php’s Output Caching with PHP, PHPit’s How to build a simple caching system, with PHP

Related posts:

  1. Word Press problem
  2. Digital Camera Problem
  3. blog machine
  4. Very Basic PHP
  5. fstab problem
This entry was posted in Web/Print Design and Dev. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Welcome to Daigo’s Daily Digital Diorama. I blog about... whatever that comes to my mind.
  • Change color

    Purple Red Green Blue No Style

  • Archives

  • Calendar

    February 2006
    M T W T F S S
    « Jan   Mar »
     12345
    6789101112
    13141516171819
    20212223242526
    2728  
  • Categories