Skip to content

Instantly share code, notes, and snippets.

View smonteverdi's full-sized avatar

Sean Monteverdi smonteverdi

View GitHub Profile
@smonteverdi
smonteverdi / gist:1993937
Created March 7, 2012 15:55
PHP: Login Form
login_page.php
<form action="verify.php" method="post">
User Name:<br>
<input type="text" name="username"><br><br>
Password:<br>
<input type="password" name="password"><br><br>
<input type="submit" name="submit" value="Login">
</form>
verify.php
@smonteverdi
smonteverdi / gist:1993940
Created March 7, 2012 15:56
PHP: Registration Form
<?php
if(isset($_POST['submit'])){
# connect to the database here
# search the database to see if the user name has been taken or not
$query = sprintf("SELECT * FROM users WHERE user_name='%s' LIMIT 1",mysql_real_escape_string($_POST['user_name']));
$sql = mysql_query($query);
$row = mysql_fetch_array($sql);
#check too see what fields have been left empty, and if the passwords match
if($row||empty($_POST['user_name'])|| empty($_POST['fname'])||empty($_POST['lname'])|| empty($_POST['email'])||empty($_POST['password'])|| empty($_POST['re_password'])||$_POST['password']!=$_POST['re_password']){
# if a field is empty, or the passwords don't match make a message
@smonteverdi
smonteverdi / gist:1993942
Created March 7, 2012 15:56
PHP: Send Email
<?
if (isset($_REQUEST["id"]) && ($_REQUEST["id"]<>"")) {
$data1=mysql_query("SELECT * FROM your_table WHERE id=".$_REQUEST["id"]);
$data=mysql_fetch_array($data1);
$from =mymail@mydomain.com;
$to = $data["email_field"];
$user = $data["name_field"];
$subject = "Enter your subject line here"; /*or if it comes from the table*/ $subject = $data["subject_field"];
$header="From:" . $from . "\r\n " ."Reply-To:". $from ;
$body="Hello ". $user .",\n\nFirst line\n\nYour message goes here, \nbest regards,\nyour_name and such\n";
@smonteverdi
smonteverdi / gist:1993945
Created March 7, 2012 15:57
PHP: Upload Image and Create Thumbnail
<?
if ($_REQUEST['action']=="add"){
$userfile = $HTTP_POST_FILES['photo']['tmp_name'];
$userfile_name = $HTTP_POST_FILES['photo']['name'];
$userfile_size = $HTTP_POST_FILES['photo']['size'];
$userfile_type = $HTTP_POST_FILES['photo']['type'];
/////////////////////////
//GET-DECLARE DIMENSIONS //
@smonteverdi
smonteverdi / gist:2050619
Created March 16, 2012 15:43
CSS: Style Placeholders
:-webkit-input-placeholder {
font-size: 12px;
font-style: italic;
color: #CCC;
}
:-moz-placeholder {
font-size: 12px;
font-style: italic;
color: #CCC;
}
@smonteverdi
smonteverdi / gist:2156440
Created March 22, 2012 05:38
WordPress: Customize password protected message
<?php
add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form class="protected-post-form" action="' . get_option('siteurl') . '/wp-pass.php" method="post">
' . __( "This post is password protected. To view it please enter your password below:" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';
@smonteverdi
smonteverdi / theme-options.php
Created March 24, 2012 14:44
WordPress: Options Page Starter
// Load up the theme options. Put this line in your functions.php file
require_once ( get_template_directory() . '/theme-options.php' );
<?php
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
/**
@smonteverdi
smonteverdi / gist:2288580
Created April 3, 2012 01:27
WordPress: Adding Custom Fields
function fb_add_custom_user_profile_fields( $user ) {
?>
<h3><?php _e('Extra Profile Information', 'your_textdomain'); ?></h3>
<table class="form-table">
<tr>
<th>
<label for="address"><?php _e('Address', 'your_textdomain'); ?>
</label></th>
<td>
<input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br />
@smonteverdi
smonteverdi / gist:2320807
Created April 6, 2012 15:31
WordPress: Default Styles
/* =WordPress Core
-------------------------------------------------------------- */
.alignnone {
margin: 5px 20px 20px 0;
}
.aligncenter, div.aligncenter {
display:block;
margin: 5px auto 5px auto;
}
@smonteverdi
smonteverdi / gist:2344892
Created April 9, 2012 17:30
WordPress: Update admin password with a query
UPDATE `wp_users` SET `user_pass` = MD5( 'new_password_here' ) WHERE `wp_users`.`user_login` = "admin_username";