cartpauj Posted January 2, 2008 Share Posted January 2, 2008 I need a script that can check a database for a variable (dateob) the birthdate is stored in this format MM-DD-YYYY, the script needs to search all users Birthdays and if one is coming up soon send out an E-Mail to the user. I don't know anythin about PHP but would this be hard to do? would it be easier if I changed the way the date was stored? Here's the code used when the user registers if that will help you know what variables to use: // registration function wpmem_register() { // make sure native WP registration functions are loaded require_once( ABSPATH . WPINC . '/registration-functions.php'); global $wpmem_regchk, $wpmem_themsg; global $wpdb,$table_prefix; global $username,$password,$fname,$lname,$addr1,$addr2,$city, $thecity,$thestate,$zip,$country,$phone1,$email,$dateob; $username = $_POST['log']; $fname = $_POST['fname']; $lname = $_POST['lname']; $addr1 = $_POST['addr1']; $addr2 = $_POST['addr2']; $city = $_POST['city']; $thestate = $_POST['thestate']; $zip = $_POST['zip']; $country = $_POST['country']; $phone1 = $_POST['phone1']; $email = $_POST['email']; $dateob = $_POST['dateob']; // check for required fields if ( !$email ) { $wpmem_themsg = "email is a required field"; } if ( !$phone1 ) { $wpmem_themsg = "phone is a required field"; } if ( !$country ) { $wpmem_themsg = "country is a required field"; } if ( !$zip ) { $wpmem_themsg = "zip is a required field"; } if ( !$thestate ) { $wpmem_themsg = "state is a required field"; } if ( !$city ) { $wpmem_themsg = "city is a required field"; } if ( !$addr1 ) { $wpmem_themsg = "address is a required field"; } if ( !$lname ) { $wpmem_themsg = "last name is a required field"; } if ( !$fname ) { $wpmem_themsg = "first name is a required field"; } if ( !$username ) { $wpmem_themsg = "username is a required field"; } if ( !$dateob ) { $wpmem_themsg = "birth date is a required field"; } if ( $wpmem_themsg ) { $wpmem_regchk = "empty"; } else { if (username_exists($username)) { $wpmem_regchk = "user"; } else { $email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$email'"); if ( $email_exists) { $wpmem_regchk = "email"; } else { //everything checks out, so go ahead and insert $password = substr( md5( uniqid( microtime() ) ), 0, 7); $hashpassword = md5($password); $user_registered = gmdate('Y-m-d H:i:s'); $query = "INSERT INTO $wpdb->users (user_login, user_pass, user_email, user_registered, user_nicename, display_name) VALUES ('$username', '$hashpassword', '$email', '$user_registered', '$username', '$username')"; $query = apply_filters('create_user_query', $query); $wpdb->query( $query ); $user_id = $wpdb->insert_id; update_usermeta( $user_id, 'first_name', $fname); update_usermeta( $user_id, 'last_name', $lname); update_usermeta( $user_id, 'addr1', $addr1); update_usermeta( $user_id, 'addr2', $addr2); update_usermeta( $user_id, 'city', $city); update_usermeta( $user_id, 'thestate', $thestate); update_usermeta( $user_id, 'zip', $zip); update_usermeta( $user_id, 'country', $country); update_usermeta( $user_id, 'phone1', $phone1); update_usermeta( $user_id, 'dateob', $dateob); update_usermeta( $user_id, 'nickname', $username); //if this was successful, and you have email properly //configured, send a notification email to the user wpmem_inc_regemail($user_id,$password); // successful registration message $wpmem_regchk = "success"; } } } } // end of registration function Link to comment https://forums.phpfreaks.com/topic/84152-solved-help-with-php-script/ Share on other sites More sharing options...
revraz Posted January 2, 2008 Share Posted January 2, 2008 Using either the MySQL Date or a Unix Timestamp would make it a lot easier. would it be easier if I changed the way the date was stored? Link to comment https://forums.phpfreaks.com/topic/84152-solved-help-with-php-script/#findComment-428371 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.