当前位置: 首页>>代码示例>>PHP>>正文


PHP run_mysql_query函数代码示例

本文整理汇总了PHP中run_mysql_query函数的典型用法代码示例。如果您正苦于以下问题:PHP run_mysql_query函数的具体用法?PHP run_mysql_query怎么用?PHP run_mysql_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了run_mysql_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register_user

function register_user($post)
{
    $_SESSION['errors'] == array();
    if (empty($post['first_name'])) {
        $_SESSION['errors'][] = "first name can't be blank";
    }
    if (empty($post['last_name'])) {
        $_SESSION['errors'][] = "last name can't be blank";
    }
    if (empty($post['password'])) {
        $_SESSION['errors'][] = "password field must not be blank";
    }
    if ($post['password'] !== $post['confirm_password']) {
        $_SESSION['errors'][] = "passwords must match!";
    }
    if (!filter_var($post['email'], FILTER_VALIDATE_EMAIL)) {
        $_SESSION['errors'][] = "please use a valid email address!";
    }
    if (count($_SESSION['errors']) > 0) {
        header('location: index.php');
        die;
    } else {
        $query = "INSERT INTO users (first_name, last_name, password, email, created_at, updated_at) VALUES ('{$post['first_name']}','{$post['last_name']}','{$post['password']}','{$post['email']}',NOW(),NOW())";
        run_mysql_query($query);
        $_SESSION['success_message'] = 'User successfully created!';
        header('location: index.php');
    }
    //		var_dump($_SESSION);
    header('location: index.php');
    die;
}
开发者ID:jreyles,项目名称:lamp-stack,代码行数:31,代码来源:process.php

示例2: register_user

function register_user($post)
{
    $_SESSION['errors'] = array();
    if (empty($post['first_name'])) {
        $_SESSION['errors'][] = "First name cannot be blank.";
    }
    if (empty($post['last_name'])) {
        $_SESSION['errors'][] = "Last name cannot be blank.";
    }
    if (empty($post['password'])) {
        $_SESSION['errors'][] = "Password field is required.";
    }
    if ($post['password'] !== $post['confirm_password']) {
        $_SESSION['errors'][] = "Passwords don't match.";
    }
    if (!filter_var($post['email'], FILTER_VALIDATE_EMAIL)) {
        $_SESSION['errors'][] = "Invalid email address.";
    }
    //validate for duplicate registration by email
    if ($post['email'] === $post['email']) {
        $_SESSION['errors'][] = "Email already registered. Please log in.";
    }
    if (count($_SESSION['errors']) > 0) {
        header("Location: index.php");
        die;
    } else {
        $query = "INSERT INTO users (first_name, last_name, password, email, created_at, updated_at) \n\t\t\t\t  VALUES ('{$post['first_name']}', '{$post['last_name']}', '{$post['password']}', '{$post['email']}', NOW(), NOW())";
        run_mysql_query($query);
        $_SESSION['success_message'] = "Successful registration! Please log in.";
        header("Location: index.php");
        die;
    }
}
开发者ID:ppaulino,项目名称:login-reg-with-DB,代码行数:33,代码来源:process.php

示例3: register_user

function register_user($post)
{
    $_SESSION['errors'] = array();
    if (empty($post['first_name'])) {
        $_SESSION['errors'][] = "first name can't be blank";
    }
    if (empty($post['last_name'])) {
        $_SESSION['errors'][] = "last name can't be blank";
    }
    if (empty($post['password'])) {
        $_SESSION['errors'][] = "password field is required";
    }
    if (!filter_var($post['email'], FILTER_VALIDATE_EMAIL)) {
        $_SESSION['errors'][] = "must be valid email";
    }
    if ($post['password'] !== $post['confirm_password']) {
        $_SESSION['errors'][] = 'passwords must match';
    }
    ///-------------end of validation checks-----------//
    if (count($_SESSION['errors']) > 0) {
        header('Location: index.php');
        die;
    } else {
        $query = "INSERT INTO users (first_name, last_name, password, email, created_at, updated_at)\r\n\t\t\t\t\tVALUES ('{$post['first_name']}', '{$post['last_name']}', '{$post['password']}', '{$post['email']}', NOW(), NOW())";
        run_mysql_query($query);
        $_SESSION['success_message'] = 'User succesfully created';
        header("Location: index.php");
        exit;
    }
}
开发者ID:aespidol,项目名称:wall,代码行数:30,代码来源:process.php

示例4: register_user

function register_user($post)
{
    //--------------being of validation checks-----------------------//
    $_SESSION['errors'] = array();
    if (empty($post['first_name'])) {
        $_SESSION['errors'][] = "First name can't be blank";
    }
    if (empty($post['last_name'])) {
        $_SESSION['errors'][] = "Last name can't be blank";
    }
    if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        $_SESSION['errors'][] = "Please enter a valid email address";
    }
    if (empty($post['password']) || empty($post['confirm_password'])) {
        $_SESSION['errors'][] = "Password field is required";
    }
    if ($post['password'] !== $post['confirm_password']) {
        $_SESSION['errors'][] = "Password must match";
    }
    //--------------end of validation checks-----------------------//
    if (count($_SESSION['errors']) === 0) {
        $query = "INSERT INTO users (first_name, last_name, email, password, created_at, updated_at)\n\t\t\t\t\t  VALUES ('{$_POST['first_name']}', '{$_POST['last_name']}', '{$_POST['email']}', '{$_POST['password']}', NOW(), NOW())";
        run_mysql_query($query);
        $_SESSION['message'] = "Registration Successful!";
    }
    header("Location: index.php");
}
开发者ID:kchirayus,项目名称:login_registration,代码行数:27,代码来源:process.php

示例5: register_user

function register_user($post)
{
    // --------begin val checks---------------
    $_SESSION['errors'] = array();
    if (empty($post['first_name'])) {
        $_SESSION['errors'][] = "first name can't be blank";
    }
    if (empty($post['last_name'])) {
        $_SESSION['errors'][] = "last name can't be blank";
    }
    if (empty($post['password'])) {
        $_SESSION['errors'][] = "password can't be blank";
    }
    if ($post['password'] !== $post['confirm_password']) {
        $_SESSION['errors'][] = "password must match";
    }
    if (!filter_var($post['email'], FILTER_VALIDATE_EMAIL)) {
        $_SESSION['errors'][] = "please use a valid email";
    }
    //-------end of validation checks
    if (count($_SESSION['errors']) > 0) {
        //if there's any errors at all
        header('location: index.php');
        die;
    } else {
        //insert database
        $query = "INSERT INTO users (first_name, last_name, email, password, created_at, updated_at)\n\t\tVALUES ('{$post['first_name']}','{$post['last_name']}','{$post['email']}','{$post['password']}',NOW(),NOW())";
        run_mysql_query($query);
        $_SESSION['success_message'] = 'Yay, you did it!';
        header('location: index.php');
        die;
    }
}
开发者ID:ronksim,项目名称:the-wall,代码行数:33,代码来源:process.php

示例6: post_comments

function post_comments()
{
    $comment = escape_this_string($_POST["comment"]);
    $query = "INSERT INTO comments (comment, created_at, updated_at, message_id, user_id)\n\t\t\t\t  VALUES ('{$comment}', NOW(), NOW(), '{$_POST['message_id']}', '{$_SESSION['user_id']}')";
    if (run_mysql_query($query)) {
        header("Location: wall.php");
    }
}
开发者ID:raymondluu,项目名称:the_wall,代码行数:8,代码来源:wall_process.php

示例7: register_user

function register_user($post)
{
    $errors = array();
    // Begin validation checks
    if (empty($_POST["first_name"])) {
        $errors[] = "Please provide a first name!";
    } else {
        if (preg_match("/[0-9]/", $_POST["first_name"])) {
            $errors[] = "Please provide a valid first name!";
        }
    }
    if (empty($_POST["last_name"])) {
        $errors[] = "Please provide a last name!";
    } else {
        if (preg_match("/[0-9]/", $_POST["last_name"])) {
            $errors[] = "Please provide a valid last name!";
        }
    }
    if (empty($_POST["email"])) {
        $errors[] = "Please provide an email!";
    } else {
        if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
            $errors[] = "Please provide a valid email!";
        }
    }
    if (empty($_POST["password"])) {
        $errors[] = "Please provide a password!";
    } else {
        if (strlen($_POST["password"]) < 7) {
            $errors[] = "Please provide a password that has at least 6 characters!";
        }
    }
    if (empty($_POST["c_password"])) {
        $errors[] = "Please confirm password";
    } else {
        if ($_POST["password"] != $_POST["c_password"]) {
            $errors[] = "Please provide a matching password!";
        }
    }
    // End of validation checks
    if (count($errors) > 0) {
        $_SESSION["errors"] = $errors;
        header("Location: index.php");
        die;
    } else {
        $first_name = escape_this_string($_POST["first_name"]);
        $last_name = escape_this_string($_POST["last_name"]);
        $email = escape_this_string($_POST["email"]);
        $password = escape_this_string($_POST["password"]);
        $query = "INSERT INTO users (first_name, last_name, email, password, created_at, updated_at)\n\t\t\t\t\t  VALUES ('{$first_name}', '{$last_name}', '{$email}', '{$password}', NOW(), NOW())";
        if (run_mysql_query($query)) {
            $_SESSION["success"] = "You have successfully registered!";
            header("Location: index.php");
            die;
        }
    }
}
开发者ID:raymondluu,项目名称:the_wall,代码行数:57,代码来源:process.php

示例8: wall_post

function wall_post($wall_post)
{
    $query = "INSERT INTO messages (message, created_at, updated_at, users_id)\n\tVALUES ('{$wall_post['wall']}', NOW(), NOW(), {$_SESSION['user_id']})";
    // var_dump($query);
    // die();
    run_mysql_query($query);
    header('location: success.php');
    die;
}
开发者ID:ronksim,项目名称:the-wall,代码行数:9,代码来源:message.php

示例9: register_user

function register_user($post)
{
    $_SESSION['errors'] = array();
    // Assigning more secure variables to important fields using escape_this_string function
    $username = escape_this_string($post['username']);
    $email = escape_this_string($post['email']);
    $password = escape_this_string($post['password']);
    // Beginning of validation checks
    // Attempt at validating existing information
    $check_data_query = "SELECT users.username, users.email FROM users";
    $existing_users = fetch_all($check_data_query);
    if (!empty($existing_users)) {
        foreach ($existing_users as $user) {
            if ($username == $user['username']) {
                $_SESSION['errors'][] = 'This username is already taken.';
            }
            if ($email == $user['email']) {
                $_SESSION['errors'][] = 'This email is already in use.';
            }
        }
    }
    // Validating non-existing information to make sure nothing is blank or invalid
    if (empty($username)) {
        $_SESSION['errors'][] = "Username cannot be blank.";
    }
    if (empty($post['first_name'])) {
        $_SESSION['errors'][] = "First name cannot be blank.";
    }
    if (empty($post['last_name'])) {
        $_SESSION['errors'][] = "Last name cannot be blank.";
    }
    if (empty($password)) {
        $_SESSION['errors'][] = "Password fields cannot be blank.";
    }
    if ($post['password'] !== $post['confirm_password']) {
        $_SESSION['errors'][] = "Passwords must match.";
    }
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $_SESSION['errors'][] = "Please use a valid email address.";
    }
    if (count($_SESSION['errors']) > 0) {
        header('Location: main.php');
        exit;
    } else {
        // Here I am gonna encrypt both the email and password and then I'm going to make a query to insert that data into the database
        $salt = bin2hex(openssl_random_pseudo_bytes(22));
        $encrypted_password = md5($password . '' . $salt);
        $query = "INSERT INTO users (username, first_name, last_name, email, password, salt, created_at, updated_at) \n\t\t\t  \t\t  VALUES ('{$username}', '{$post['first_name']}', '{$post['last_name']}', '{$email}', '{$encrypted_password}', '{$salt}', NOW(), NOW())";
        run_mysql_query($query);
        $_SESSION['success'] = "User has been successfully created!";
        header('Location: main.php');
        exit;
    }
}
开发者ID:aquang9124,项目名称:the_wall,代码行数:54,代码来源:process.php

示例10: comment_action

function comment_action($post)
{
    if (!empty($post['comment'])) {
        $comment_query = "INSERT INTO comments (users_id, messages_id, comment, created_at, updated_at) \n\t\t\t\t\t\t  VALUES (" . $_SESSION['user_id'] . ", '{$post['messages_id']}', '{$post['comment']}', NOW(), NOW())";
        run_mysql_query($comment_query);
        header("Location: wall.php");
    } else {
        $_SESSION['errors'][] = "Comment field cannot be empty.";
        header("Location: wall.php");
        die;
    }
}
开发者ID:ppaulino,项目名称:the-wall,代码行数:12,代码来源:process.php

示例11: user_message

function user_message($post)
{
    $_SESSION['errors'] = array();
    if (empty($post['message'])) {
        $_SESSION['errors'][] = "Message cannot be blank";
    }
    //----------No Errors then run query------------//
    if (count($_SESSION['errors']) == 0) {
        $query = "INSERT INTO wall.messages (message, created_at, updated_at, users_id) VALUES ('{$_POST['message']}', NOW(), NOW(), {$_SESSION['user_id']});";
        $_SESSION['success_message'] = "Your message has successfully been posted!";
        run_mysql_query($query);
    }
}
开发者ID:Eggsix,项目名称:dojo_projects,代码行数:13,代码来源:message_process.php

示例12: gawa_ng_kalendaryo

 public function gawa_ng_kalendaryo($year)
 {
     $numberOfDays = 390;
     $newdayofweek = 1;
     $weekNumber = 1;
     $days = "+0 days";
     // check table for the last date on the the table
     $query = "SELECT juliandate FROM fiscalcalendar ORDER BY juliandate desc Limit 1";
     $result = fetch_record($query);
     if ($result['juliandate'] == 0) {
         $juliandate = gregoriantojd(01, 01, date('Y', strtotime($year)));
     } else {
         $juliandate = $result['juliandate'] + 1;
     }
     // $juliandate = gregoriantojd(01,01,date('Y',strtotime($days)));
     echo "<table border='5px'><thead><td>Julian Date</td><td>Gregorian Date</td><td>end of week</td><td>end of month</td><td>week#</td></thead><tbody>";
     for ($i = 0; $i <= $numberOfDays; $i++) {
         // check for end of week
         $days = JDToGregorian($juliandate);
         if (date('N', strtotime($days)) == 7) {
             $endOfWeek = 'Y';
         } else {
             $endOfWeek = 'N';
         }
         // end of year
         if (date("m", strtotime($days)) == 12 && date("j", strtotime($days)) == date("t", strtotime($days))) {
             $endofyear = 'Y';
         } else {
             $endofyear = 'N';
         }
         // end of month
         if (date("j", strtotime($days)) == date("t", strtotime($days))) {
             $endofmonth = 'Y';
         } else {
             $endofmonth = 'N';
         }
         if (date("j", strtotime($days)) == 1) {
             $weekNumber = 1;
             $newdayofweek = date('N', strtotime($days));
         } else {
             if ($newdayofweek == date('N', strtotime($days))) {
                 $weekNumber += 1;
             }
         }
         echo "<tr>" . $juliandate . '</td><td>' . JDToGregorian($juliandate) . '</td><td>' . $endOfWeek . '</td><td>' . $endofmonth . '</td><td>' . $weekNumber . '</td></tr>';
         $query = "INSERT INTO fiscalcalendar (juliandate,fdate, fmonth, fday, fyear, endOfWeek, endofmonth,  dayOfWeek, weekNumber) VALUES('" . $juliandate . "','" . date("y-m-d", strtotime($days)) . "'," . date("m", strtotime($days)) . "," . date('j', strtotime($days)) . "," . date('Y', strtotime($days)) . ",'" . $endOfWeek . "','" . $endofmonth . "','" . date('N', strtotime($days)) . "'," . $weekNumber . ")";
         $result = run_mysql_query($query);
         $juliandate += 1;
     }
 }
开发者ID:eddiebanz,项目名称:tourism,代码行数:50,代码来源:mga_kalendaryo.php

示例13: insert_query_comment

function insert_query_comment($post)
{
    $content = escape_this_string($post['content']);
    $query = "INSERT INTO comments\n\t\t\t\t\t(content, created_at, updated_at,post_id,user_id)\n\t\t\t\t\tvalues\n\t\t\t\t\t('{$content}',now(),now(),{$_POST['post_id']},{$_SESSION['user_id']});";
    if (run_mysql_query($query)) {
        // run query here
        header('Location: wall.php');
        return true;
    } else {
        var_dump($post);
        die("System Error");
    }
    //return
}
开发者ID:stormywake,项目名称:the-wall,代码行数:14,代码来源:post_process.php

示例14: post_comment

function post_comment($post)
{
    if (empty($post['comments'])) {
        $_SESSION['errors'][] = "Please submit a comment.";
        header("Location: success.php");
        exit;
    } elseif (!empty($post['comments'])) {
        $query = "INSERT INTO comments (comment, created_at, updated_at, users_id, messages_id)\r\n\t\t\t\tVALUES ('{$post['comments']}', NOW(), NOW(), '{$post['user_id']}', '{$post['message_id']}')";
        run_mysql_query($query);
        $query = "SELECT * FROM users\r\n\t\t\t\tLEFT JOIN comments\r\n\t\t\t\tON users.id = comments.users_id";
        $_SESSION['comments'] = fetch_all($query);
        header("Location: success.php");
        die;
    }
}
开发者ID:aespidol,项目名称:wall,代码行数:15,代码来源:wall_process.php

示例15: insert_comment

function insert_comment($post)
{
    // Making sure that comment is not empty, don't want any empty comments clogging up my database
    if (empty($post['comment'])) {
        $_SESSION['blank'] = "Your comment cannot be blank!";
        header('Location: wall.php');
        exit;
    }
    if (!empty($post['comment'])) {
        $query = "INSERT INTO comments (message_id, user_id, comment, created_at, updated_at) \n\t\t\t\t\t  VALUES ('{$post['message_id']}', '{$_SESSION['user_id']}', '{$post['comment']}', NOW(), NOW())";
        run_mysql_query($query);
        header('Location: wall.php');
        exit;
    }
}
开发者ID:aquang9124,项目名称:the_wall,代码行数:15,代码来源:process_text.php


注:本文中的run_mysql_query函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。