AJAX Contact Form updated
Design, development, php, web 2.0 February 23rd, 2010
I just updated http://www.whathuhstudios.com/press/2008/01/04/ajax-contact-form-quick-install/ to version 1.6, updated JQuery to 1.4, fixed some validation bugs, etc. It’s still simple and small. Go grab it. You’ll be glad. Maybe.
Tags: ajax, development, forms, jquery, php, tips, tools, web 2.0
Anonymous Twitter – Another useless Whathuh Studios service
Microblogging, development, php, portfolio June 12th, 2009
Ever do, see, or think something stupid? Ever feel like you want to get something off your chest that is tweetworthy, but wouldn’t be caught dead actually telling it to anyone? I have. Many times. I decided to do something about it.
Thus, http://www.anontwit.com was created.
Be sure to follow @anontw to see what other random people are saying over the interwebs.
Have fun!
Tags: Microblogging, php, tools, twitter
Drop-In Ajax Contact Form Updated
Design, development, php, web 2.0 February 26th, 2009
I just updated http://www.whathuhstudios.com/press/2008/01/04/ajax-contact-form-quick-install/ to version 1.5, reworked with JQuery, and trimmed the size down to about 33% of what it used to be. Check it out for a quick and easy way to add some Ajax Class© to your website!
Tags: ajax, development, forms, jquery, php, tips, tools, web 2.0
PHP if statement alternatives
development, php September 7th, 2008
Did you know there are actually 3 different ways to use the if…else…elseif control in PHP? They each have their uses, and hopefully I can help decode them a little bit for those who aren’t familiar with them. Here is your standard if statement:
if ($islocal) {
$user = "localhost";
} else {
$user = $logged_in_user;
}
if ($isadmin) {
$ip = "192.168.0.1";
} else {
$ip = "localhost";
}
Now, there is nothing wrong with that, but if you’re looking for something a bit cleaner, you could try it this way:
$user = ($islocal) ? "localhost" : $logged_in_user; $ip = ($isadmin) ? "192.168.0.1" : "localhost";
Less code. Less mess. Less parsing time. Very nice. Now, what about dynamically generating html pages? I’ll use a short example of the standard way, but in practice they get quite a bit more complicated and tough to read. Here’s an example of a form the standard way:
<?php
if ($isloggedin) {
echo "<form name = 'myform' action = 'submit.php' method = 'post'>";
echo "<input name = 'firstname' value = '{$user['firstname']}'
type = 'text' />";
echo "<input name = 'lastname' value = '{$user['lastname']}'
type = 'text' />";
echo "</form>";
} else {
echo "<div class = 'errormessage'>You are not logged in.</div>";
echo "<div class = 'infotext'><p>Please <a href = 'login.php'>login
</a> or <a href = 'register.php'>register</a> before attempting
to edit your profile</p></div>";
}
?>
Now like I said, this one isn’t so bad. but imagine if you needed to display much more website content, and had to do it that way. Also, this has the caveat of being very unfriendly with any sort of visual editor like Dreamweaver. Here’s a better way:
<?php if ($isloggedin) : ?>
<form name = 'myform' action = 'submit.php' method = 'post'>
<input name = 'firstname' value = '<?php echo $user['firstname'] ?>'
type = 'text' />
<input name = 'lastname' value = '<?php echo $user['lastname']} ?>'
type = 'text' />
</form>
<?php else: ?>
<div class = 'errormessage'>You are not logged in.</div>
<div class = 'infotext'><p>Please <a href = 'login.php'>login</a> or
<a href = 'register.php'>register</a> before attempting to edit your
profile</p></div>
<?php endif; ?>
Now, this doesn’t save a whole lot of code space, but it does make everything a bit more readable. It also allows you to see exactly what you’re working with in something like dreamweaver, and copy and paste large amounts of code without having to scroll down line by line and copy/paste/copy/paste…
Hopefully these will help save some of you some time. Good luck, and happy coding!
Tags: code, coding, development, else, endif, if, php, then, tips
Free PHP authentication Script
development, php August 31st, 2008
This is a quick and dirty solution. Because of that… it is oh so easy and simple.
Included in this zip file are 6 files:
header.php
include.php
footer.php
loginform.php
checklogin.php
index.php (sample implementation)
style.css (for ugliness!)
It’s very very simple. Any page that the user needs to be logged in to access, include the header.php file at the very beginning of your page, and the footer.php (optional, cleaner code) at the bottom.
You’ll have to manually create the database, and create a table (named “login_users” by default). The table should have two fields: username and password. Create as many users as you want, and feel free to edit and reuse this code as much as you’d like. All you should need to edit to get this working are the variables at the top of the include.php file. I consider this an alpha release, and hope to get some feedback telling me that it works as expected.
Download loginscript_alpha1.zip
