Git Force Push Branch

I had a problem where I want to push my branch and overwrite what was the on the server.

I kept receiving an error telling me to merge. I did not want to merge and found a way to force push a branch.

In general you don’t want to do this unless you absolutely have to.

git push -f origin <branch>

This Stackoverflow question and answers helped me.

http://stackoverflow.com/questions/10298291/cannot-push-to-github-keeps-saying-need-merge

Mod Rewrite Enabled But Not Working

If you find that your mod rewrite is enabled, but doesn’t seem to be working you may need to add this little bit of code to your httpd.conf file.

AllowOverride All

It’s possible your file might have the following:

AllowOverride None

If your AllowOverride was set to none then your .htaccess files in your project directory are not able to set their own settings including url rewriting.

Make sure to restart Apache after applying this change to your httpd.conf file.

 

The following link helped me solve my problem.

http://stackoverflow.com/questions/17772962/laravel-4-simple-route-not-working-using-mod-rewrite-and-htaccess

Xampp Send Email Issues

After upgrading my xampp installation I had issues sending email.

I wrote a small test PHP page and it was saying my emails were being sent, but I never received them. Obviously something was misconfigured.

I thought I correctly edited my php.ini file, but it turns out all the tinkering I did with it may have caused the issues.

Search your php.ini file for [mail function].

  1. Remove the comment on smtp and smtp_port by removing the semi colons before them.
  2. Add smtp server, port number. I’m using my ISP smtp server. Find your ISP smtp settings by searching google.
  3. sendmail_from needs to be set only if you don’t specify a from header in your PHP code. This can be set to any email address.
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = examplesmtpserver.com
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = email you want to send from (ex: [email protected]). This needs to be set or a from header must be added in the php mail code

 

Here is test PHP code that I used. You’ll have to edit the “to” variable to your email address.

$to = "your email here";
$subject = "Test Email";
$body = "Email for testing Xampp";

if (mail($to, $subject, $body)){
	echo("Message successfully sent!");
} 
else{
	echo("Message delivery failed…");
}

After visiting your created PHP page the page should tell you whether PHP sent your email. Please note that just because PHP says it sent the mail doesn’t actually mean the email will be delivered  While I was having issues PHP still said it successfully sent, but I wasn’t receiving emails. If you’re still having problems after it says email successfully sent you’ll have to do more digging.

Contact me if you have questions I’ll do my best to assist [email protected].

 

 

Build Email Message Dynamically From Submitted Form

I wrote some code to dynamically generate an email message based on the names of form elements being sent through post.
In this post I’ll describe how it’s done.

The foreach loop grabs the keys from the post array. An example key for this  $_POST[‘Name’] would be “Name”. It’s important to put in the name of the field how you want it to show in the email. So if you want uppercase letters or spaces put them in.

The $keywos (key without spaces) gets the current key in the foreach loop and replaces the underscores that are automatically put in if the name from the HTML form elements had spaces when posting and replaces them with spaces.

Copy the post array to values array

If the current value for a particular key doesn’t have information in it don’t add it to the email message. This means the user hasn’t typed in any information in the input or selected an option.

If the key isn’t equal to submit then add it to the email messages. The submit button doesn’t need to be added to the email message.

 

Have questions? Email me at [email protected].

Understanding AJAX In WordPress Plugins

For me it’s difficult to retain and grasp the programming concept, especially if it’s new, if I don’t understand the why behind the concept. I didn’t  understand how to properly use AJAX in WordPress. I started searching google and found many article explaining how to use it. The problem was it didn’t go into enough detail for me to understand why. The articles said do it this way, but didn’t explain.

The following article from Smashing Magazine goes into great detail on how to use AJAX in WordPress.
http://wp.smashingmagazine.com/2011/10/18/how-to-use-ajax-in-wordpress/

Send me an email [email protected] if you have questions.