Archive for the ‘MySQL’ Category

iMeetzu Meetzing the iPhone VERY soon

30
Oct 2009

My iMeetzu app has been sluggishly working it’s way through the approval process of what seems to be 1/2 of an employee at Apple approving these things. Just Joshin’ ya Jobs, but it honestly was under approval for about 8 weeks before we got a response telling us to make some changes before it can be accepted.  Making changes to an app means getting to the back of the line to be approved again.  The required adjustments have been made and we’re sitting in line again waiting for this thing to get pushed public.  Since I’ve had all this time to think about the app, I cleaned it up a ton and made a short video demo attached here at the bottom of this post.  Check it out and let me know what you think.




I changed the layout quite a bit. The colors match the new iMeetzu site and I did away with the iPhone style chat bubbles. I thought the bubbles were going to be great, but I realized the only thing awesome about them was how hard they were to build in CSS. They made the app look cheap, and its not! So I had to get rid of those and simplify the chat box with a white background and a single line between messages. Plus I like having it say “You” and “Stranger” in the all too infamous red and blue colors.

My final thought on the app is to add in some of the advanced features from the site such as smilies and images. I haven’t decided on this yet, but I imagine some of these cool features from the full version of iMeetzu will find their way to the iPhone app. Luckily most of the changes to the app can be done via some files hosted on one of my servers, so we won’t always have to wait 2 months in between versions!

iMeetzu Widget - Chat with a stranger on your own website

10
Aug 2009

I got a great idea from a fellow webmaster this weekend to make a widget out of my iMeetzu application. What a great way to spread the word around about the site. I spent a better part of my day Saturday making a lightweight version of iMeetzu that anyone can put on their site with just a small snippet of code. I actually have put this widget here on my blog as well. You can check it out on the right side of the page. The widget is integrated with the main system, so you could potentially chat from the widget with another user on the main site. Also you could be chatting through the widget from two separate websites. My hope is that the widget will get picked up by a lot of bloggers and help iMeetzu grow considerably.

Visit the iMeetzu Widget page to put iMeetzu on your site. The widget allows an adjustable size to fit nicely into your site.

Project iMeetzu.com - Talking To Strangers Online

6
Aug 2009

A couple of weeks ago I built this site iMeetzu. Basically you just go to the website and click the button to meet a stranger. There is not much else to it. You have a few options once you are actually engaged in a conversation with a stranger. The options are very basic and are as follows:

  • Turns sounds on and off
  • Change Your Name
  • Input your Gender
  • Choose a Gender to Chat With

These are just basic options to change the visitors experience. Nothing too complex. I didn’t want to complicate the site and ruin the entire point of it.

This idea came about from a similar site. I saw it and was pretty amazed at the simplicity of the idea, but I knew it was not a simple project to build. I saw some obvious room for new features to make the site better, so I decided to build my own. It didn’t take as long as I thought. I build the site from scratch in about a day.

More features will be coming out to make the site even more entertaining. If you have any ideas please leave them as a comment here and submit them in the feedback form on the iMeetzu website.

Efficient and Flexible Forms With PHP and MySQL

4
Dec 2008

Posting information from a form on your website into a MySQL database is a pretty basic thing, and it is one of the most common functions of any website.  I’ve had to re-create indentical scripts over and over to accomplish this simple task. So with saving time in mind, I finally just built a ‘flexible’ or ’scalable’ method of posting information to the database right from the form.  The idea here is to create some code that will work when I add and remove form fields and not have any effect on the PHP portion of the page.  I’ll just get right to it…

All of this would be in a file called addMember.php

Super simple form HTML:
———————————————–
<form action=”addMember.php” method=”post”>
<table border=”0″>
<tbody>
<tr>
<td>First Name</td>
<td><input name=”memberFirstName” size=”30″ type=”text” /></td>
</tr>
<tr>
<td>Last Name</td>
<td><input name=”memberLastName” size=”30″ type=”text” /></td>
</tr>
<tr>
<td>Phone Number</td>
<td><input name=”memberPhone” size=”30″ type=”text” /></td>
</tr>
<tr>
<td>Email</td>
<td><input name=”memberEmail” size=”30″ type=”text” /></td>

</tr>
<tr>
<td></td>
<td><input type=”submit” name=”submitMember” value=”Add” /></td>
</tr></tbody></table>
</form>
———————————————–

Thats it for the form field’s HTML. Just a couple of basic fields to collect contact data about a person. Now rather than creating some PHP to specifically map these form fields to the database column names, I am going to do something a bit different.  Check it out:

———————————————–

<?
//This is the code to be called when the form is submitted:
//if the form has been submitted
if(isset($_POST['submitMember']))
{
$keys = array(); //array for form keys
$values = array();//array for the data
$add = array_map(’mysql_real_escape_string’,$_POST); //safety first

//loop through each form field submitted in the $_POST array
foreach($add as $k => $v)
{
//if it is prefixed with ‘member’ it needs to be inserted to the database
if(ereg(’member’,$k))
{
$keys[] = str_replace(’member’,”,$k);//store the key (form field without ‘member’ prefix)
$values[] = “‘”.$v.”‘”; //store the corresponding data
}//if member
}//for each
//if atleast 1 form field has a ‘member’ prefix, store them to the database
if(count($keys)>1)
{
$key = implode(’,',$keys);//comma separate
$value = implode(’,',$values);//comma serparate
$sql = “INSERT INTO `user` (”.$key.”) VALUES (”.$value.”)”;
mysql_query($sql) or die(’Problem Adding User: ‘ . mysql_error() );
$msg = ‘<b>User successfully added to the database</b><br />’;
}//if count
}//if form submitted
?>

———————————————–

Note: I did have this tabbed out very neatly, but it didn’t appear in the post that way after I saved it, sorry.

What I did here is build an INSERT statement using the form field values as the table column name values, well almost. I prefixed the name of form fields with ‘member’ if I want it to be inserted to the database. This allows us to have form fields in the same form that don’t have to be inserted to the database, but can be used for anything else. The main key here is to match up your column names in the database to the form field names on your form.  So a column in the database named “Address” would need to have a form field name of “memberAddress” to correctly line up when it comes time to input the data from the form to the database. This is likely a commonly used method of storing data, but I’ve seen plenty of times where it is not. This little trick will likely save you a lot of time down the road with your form submission scripts. You can almost copy and paste to use it over and over. The only real changes to be made are your table names and some form field names.

And that is it. Nothing too complex here, just a little technique I came up with and thought I’d share!