Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function Email_gogo() {
- if(!empty($_POST['email']))
- {
- $mysql_hostname = '*****';
- $mysql_username = '*****';
- $mysql_password = '*****';
- $mysql_dbname = '*****';
- try {
- $db= new PDO("mysql:host=$mysql_hostname;dbname=$mysql_dbname", `enter code here`$mysql_username, $mysql_password);
- $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- exit( $e->getMessage() );
- }
- $query_email = "
- SELECT
- email
- from users
- where
- email = :email
- ";
- $query_goes = array(
- ':email' => $_POST['email']
- );
- Try{
- $stmt = $db->prepare($query_email);
- $stmt ->execute($query_goes);
- while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
- }
- }
- catch(PDOException $ex){
- echo 'ERROR: '. $ex->getMessage();
- }
- if($stmt->rowCount() > 0){
- echo("That Email is already in use...");
- }
- }
- }
- ?>
- <?php
- require("common.php");
- require_once("gogo.php");
- if(empty($_SESSION['user']))
- {
- header("Location: ../hound/login.php");
- die("Redirecting to ../hound/login.php");
- }
- if(!empty($_POST))
- {
- if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
- {
- die("Please enter a valid email address...");
- }
- }
- Email_gogo();
- $array_value = array(
- ':email' => $_POST['email'],
- ':first_name' => $_POST['first_name'],
- ':last_name' => $_POST['last_name'],
- ':id' => $_POST['id']
- );
- $query = "UPDATE users
- SET
- email = :email,
- first_name = :first_name,
- last_name = :last_name
- WHERE
- id = :id
- ";
- try
- {
- $stmt = $db->prepare($query);
- $result = $stmt->execute($array_value);
- }
- catch(PDOException $ex)
- {
- die("Ouch, failed to run query: " . $ex->getMessage());
- }
- header("Location: users.php");
- die("Redirecting to users.php");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement