SitePoint Sponsor

User Tag List

Page 5 of 6 FirstFirst 123456 LastLast
Results 101 to 125 of 126
  1. #101
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    Hey sorry for the delay.
    As I understand it, the status might be marked as 0 but is marked so get rid of that condition.
    PHP Code:
    <?php
    $sql 
    "SELECT COUNT(*) as cnt
    FROM `submitted_forms` 
    WHERE status IS NULL"
    ;
    $result $db->query($sql); 
    $row $result->fetch_assoc();
    print_r($row['cnt']);
    ?>
    Hey, i've tried that already and its still not displaying correctly. Still says 0 even though theres submissions that don't have a status.

  2. #102
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    I never like using NULL in the first place as dealing zeros also count as null. Probably need to go this route.
    PHP Code:
    <?php
    $sql 
    "SELECT COUNT(*) as cnt
    FROM `submitted_forms` 
    WHERE status = ''"
    ;
    $result $db->query($sql); 
    $row $result->fetch_assoc();
    print_r($row['cnt']);
    ?>

  3. #103
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    I never like using NULL in the first place as dealing zeros also count as null. Probably need to go this route.
    PHP Code:
    <?php
    $sql 
    "SELECT COUNT(*) as cnt
    FROM `submitted_forms` 
    WHERE status = ''"
    ;
    $result $db->query($sql); 
    $row $result->fetch_assoc();
    print_r($row['cnt']);
    ?>
    Ah thank you, finally worked!!!

  4. #104
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    I never like using NULL in the first place as dealing zeros also count as null. Probably need to go this route.
    PHP Code:
    <?php
    $sql 
    "SELECT COUNT(*) as cnt
    FROM `submitted_forms` 
    WHERE status = ''"
    ;
    $result $db->query($sql); 
    $row $result->fetch_assoc();
    print_r($row['cnt']);
    ?>
    I have another problem... I'm creating a registration where if there account username and email is found, they can finish registration. Well after I hit submit I get an error, I cannot figure it out.

    Code:
    Fatal error: Call to undefined function query() on line 14
    Heres the whole code:

    Code:
    <?php session_start(); ?>
    
    <!DOCTYPE html>
    <html lang="en">
    <?php
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
    include "core/config.php";
    
    if(isset($_POST['submit']))
    {
      $username = $_POST['username'];
      $email = $_POST['email'];
    
       $check = query($db,"SELECT * FROM users WHERE Email = ".$email."");
       
      $emailCheck = null;
      $usernameCheck = null;
      while($row = mysqli_fetch_assoc($check))
    {
        
        $emailCheck = $row['Email'];
        $usernameCheck = $row['Username'];
      }
      if(!$email == $emailCheck)
      {
        echo 'Email doesn\'t exist!';
      }else{
        
        if(!$username == $usernameCheck)
        {
          echo 'Username doesn\'t exist!';
        } else
        {
          $query = $db->query("SELECT * FROM users WHERE Username = ".$username." AND Email = ".$email."");
           $_SESSION['username'] = $username;
          echo 'You have logged in, you will be redirected.';
          echo '<META HTTP-EQUIV="REFRESH" CONTENT="5;URL=page to set password.">';
        }
      }
     }
    ?>
    
    <html>
    <head>
        <title>EGN</title>
        <link href="css/application.min.css" rel="stylesheet">
        <link rel="shortcut icon" href="img/favicon.png">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <meta charset="utf-8">
        <script src="lib/jquery/jquery-2.0.3.min.js"> </script>
    <script src="lib/jquery-pjax/jquery.pjax.js"></script>
        <script src="lib/backbone/underscore-min.js"></script>
        <script src="js/settings.js"> </script>
    </head>
    <body>
    <div class="single-widget-container">
        <section class="widget login-widget">
            <header class="text-align-center">
    
                <img src="" alt="logo" height="100" width="200">
                <br></br>
                
                <h4>Please note it may take up to 7 days after you've accepted the inivtation to locate you account in the CMS</h4>
            </header>
            <div class="body">
                <form class="no-margin" method="POST">
                    <fieldset>
                        <div class="form-group no-margin">
                            <label for="username" >Username</label>
    
                            <div class="input-group input-group-lg">
                                    <span class="input-group-addon">
                                        
                                    </span>
                                <input id="username" type="username" name="username" class="form-control input-lg" placeholder="Username">
                            </div>
    
                        </div>
    
                        <div class="form-group">
                            <label for="Email" >Email</label>
    
                            <div class="input-group input-group-lg">
                                    <span class="input-group-addon">
                                        
                                    </span>
                                <input id="email" type="email" name="email" class="form-control input-lg"
                                       placeholder="Email">
                            </div>
    
                        </div>
                    </fieldset>
                    <div class="form-actions">
                        <button type="submit" name="submit" class="btn btn-block btn-lg btn-danger">
                            </span>
                            <small>Submit</small>
                        </button>
                        <div class="forgot"><a href="">Not a member? Join here!</a></div>
                    </div>
                </form>
            </div>
            <footer>
                <div class="facebook-login"><a href="register.php">Already have an account? Login here!</a>
                    
                </div>
            </footer>
        </section>
    </div>
    </body>
    </html>

  5. #105
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Is that the way you have been connecting or making queries with all your files? Don't go changing things up. And how about this way? Note: don't forget those single quotes around the variable.
    PHP Code:
    $check $db->query("SELECT * FROM users WHERE Email = '" $email "'"); 

  6. #106
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    Is that the way you have been connecting or making queries with all your files? Don't go changing things up. And how about this way? Note: don't forget those single quotes around the variable.
    PHP Code:
    $check $db->query("SELECT * FROM users WHERE Email = '" $email "'"); 
    I had it that way, but it didn't work so I tried it this way haha

  7. #107
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    Is that the way you have been connecting or making queries with all your files? Don't go changing things up. And how about this way? Note: don't forget those single quotes around the variable.
    PHP Code:
    $check $db->query("SELECT * FROM users WHERE Email = '" $email "'"); 
    Ok, this is so weird and I have no clue whats going on. Its actually giving me a headache. Its not checking anything right. This is going to be a crappy explanation because i'm a little bit confused as well and its frustrating. So, when I click submit with the fields empty, it doesn't redirect. If I type in a username, but no email, it redirects. If I type in a random username and no email it also redirects, which is bad. When I type in an email with no username, it doesn't redirect and that does what its supposed to do. I'll past my current code with a little bit of changes I made since you gave me that code.


    Code:
    <?php session_start(); ?>
    
    <!DOCTYPE html>
    <html lang="en">
    <?php
    include "core/config.php";
    
    if(isset($_POST['submit']))
    {
      $username = $_POST['username'];
      $email = $_POST['email'];
    
       $check = $db->query("SELECT * FROM users WHERE Email = '" . $email . "'");  
       
      $emailCheck = null;
      $usernameCheck = null;
      while($row = mysqli_fetch_assoc($check))
    {
        
        $emailCheck = $row['Email'];
        $usernameCheck = $row['Username'];
      }
      if(!$email == $emailCheck)
      {
        echo 'Email doesn\'t exist!';
      }else{
        
        if(!$username == $usernameCheck)
        {
          echo 'Username doesn\'t exist!';
        } else
        {
          $query = $db->query("SELECT * FROM users WHERE Username = '" . $username . "' AND Email = '" . $email . "'");
           $_SESSION['username'] = $username;
          echo 'You have logged in, you will be redirected.';
          echo '<META HTTP-EQUIV="REFRESH" CONTENT="5;URL=page to set password.">';
        }
      }
     }
    ?>
    
    <html>
    <head>
        <title>EliteGamingNetwork</title>
        <link href="css/application.min.css" rel="stylesheet">
        <link rel="shortcut icon" href="img/favicon.png">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <meta charset="utf-8">
        <script src="lib/jquery/jquery-2.0.3.min.js"> </script>
    <script src="lib/jquery-pjax/jquery.pjax.js"></script>
        <script src="lib/backbone/underscore-min.js"></script>
        <script src="js/settings.js"> </script>
    </head>
    <body>
    <div class="single-widget-container">
        <section class="widget login-widget">
            <header class="text-align-center">
    
                <img src="http://elitegamingnetwork.net/images/logo.png" alt="logo" height="100" width="200">
                <br></br>
                
                <h4>Please note it may take up to 7 days after you've accepted the inivtation to locate you account in the CMS</h4>
            </header>
            <div class="body">
                <form class="no-margin" method="POST">
                    <fieldset>
                        <div class="form-group no-margin">
                            <label for="username" >Username</label>
    
                            <div class="input-group input-group-lg">
                                    <span class="input-group-addon">
                                        
                                    </span>
                                <input id="username" type="username" name="username" class="form-control input-lg" placeholder="Username">
                            </div>
    
                        </div>
    
                        <div class="form-group">
                            <label for="Email" >Email</label>
    
                            <div class="input-group input-group-lg">
                                    <span class="input-group-addon">
                                        
                                    </span>
                                <input id="email" type="email" name="email" class="form-control input-lg"
                                       placeholder="Email">
                            </div>
    
                        </div>
                    </fieldset>
                    <div class="form-actions">
                        <button type="submit" name="submit" class="btn btn-block btn-lg btn-danger">
                            </span>
                            <small>Submit</small>
                        </button>
                        <div class="forgot"><a href="http://elitegamingnetwork.net/partner.php">Not a member? Join here!</a></div>
                    </div>
                </form>
            </div>
            <footer>
                <div class="facebook-login"><a href="register.php">Already have an account? Login here!</a>
                    
                </div>
            </footer>
        </section>
    </div>
    </body>
    </html>

  8. #108
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Check !empty() on POST user name and email before making query. Compare values with != for NOT EQUAL
    PHP Code:
    <?php session_start(); ?>

    <!DOCTYPE html>
    <html lang="en">
    <?php
    include "core/config.php";

    if(isset(
    $_POST['submit']) && !empty($_POST['username']) && !empty($_POST['email']))
    {
      
    $username $_POST['username'];
      
    $email $_POST['email'];

       
    $check $db->query("SELECT * FROM users WHERE Email = '" $email "'");  
       
      
    $emailCheck null;
      
    $usernameCheck null;
      while(
    $row mysqli_fetch_assoc($check))
    {
        
        
    $emailCheck $row['Email'];
        
    $usernameCheck $row['Username'];
      }
      if(
    $email != $emailCheck)
      {
        echo 
    'Email doesn\'t exist!';
      }else{
        
        if(
    $username != $usernameCheck)
        {
          echo 
    'Username doesn\'t exist!';
        } else
        {
          
    $query $db->query("SELECT * FROM users WHERE Username = '" $username "' AND Email = '" $email "'");
           
    $_SESSION['username'] = $username;
          echo 
    'You have logged in, you will be redirected.';
          echo 
    '<META HTTP-EQUIV="REFRESH" CONTENT="5;URL=page to set password.">';
        }
      }
     }
    ?>

    <html>
    <head>
        <title>EliteGamingNetwork</title>
        <link href="css/application.min.css" rel="stylesheet">
        <link rel="shortcut icon" href="img/favicon.png">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <meta charset="utf-8">
        <script src="lib/jquery/jquery-2.0.3.min.js"> </script>
    <script src="lib/jquery-pjax/jquery.pjax.js"></script>
        <script src="lib/backbone/underscore-min.js"></script>
        <script src="js/settings.js"> </script>
    </head>
    <body>
    <div class="single-widget-container">
        <section class="widget login-widget">
            <header class="text-align-center">

                <img src="http://elitegamingnetwork.net/images/logo.png" alt="logo" height="100" width="200">
                <br></br>
                
                <h4>Please note it may take up to 7 days after you've accepted the inivtation to locate you account in the CMS</h4>
            </header>
            <div class="body">
                <form class="no-margin" method="POST">
                    <fieldset>
                        <div class="form-group no-margin">
                            <label for="username" >Username</label>

                            <div class="input-group input-group-lg">
                                    <span class="input-group-addon">
                                        
                                    </span>
                                <input id="username" type="username" name="username" class="form-control input-lg" placeholder="Username">
                            </div>

                        </div>

                        <div class="form-group">
                            <label for="Email" >Email</label>

                            <div class="input-group input-group-lg">
                                    <span class="input-group-addon">
                                        
                                    </span>
                                <input id="email" type="email" name="email" class="form-control input-lg"
                                       placeholder="Email">
                            </div>

                        </div>
                    </fieldset>
                    <div class="form-actions">
                        <button type="submit" name="submit" class="btn btn-block btn-lg btn-danger">
                            </span>
                            <small>Submit</small>
                        </button>
                        <div class="forgot"><a href="http://elitegamingnetwork.net/partner.php">Not a member? Join here!</a></div>
                    </div>
                </form>
            </div>
            <footer>
                <div class="facebook-login"><a href="register.php">Already have an account? Login here!</a>
                    
                </div>
            </footer>
        </section>
    </div>
    </body>
    </html>
    See http://www.php.net/manual/en/languag...comparison.php

  9. #109
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    IMHO
    I don't think you should be telling them specifically what is wrong with their submission, e.g. Email doesn't exist!
    A person could keep trying until they get the email right, then move on to the username. A general message for both would be better like
    "The information supplied doesn't match our records".

  10. #110
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    IMHO
    I don't think you should be telling them specifically what is wrong with their submission, e.g. Email doesn't exist!
    A person could keep trying until they get the email right, then move on the the username. A general message for both would be better like
    "The information supplied doesn't match our records".
    Thanks! Yeah I should do that haha, smart idea

  11. #111
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    IMHO
    I don't think you should be telling them specifically what is wrong with their submission, e.g. Email doesn't exist!
    A person could keep trying until they get the email right, then move on to the username. A general message for both would be better like
    "The information supplied doesn't match our records".
    Alright, i'm sorry I keep bothering you, I'm very new to php as you can tell and you have helped me so much and I really appreciate it. I'm now trying to create a messaging system, but I really don't know where to start, any help?

  12. #112
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Goodness, you are opening a can of worms. No really this is a topic best taken up in the design form.

    I guess the basics would be to have a table `messages`

    `id` int(12) NOT NULL AUTO_INCREMENT
    `subject` varchar(65)
    `message` text NOT NULL
    `receiver_id` varchar(10)
    `sender_id` varchar(10)
    `date_sent` DATETIME or TIMESTAMP
    `read` int(1) for 0 - 1 default 0
    `date_read` DATETIME or TIMESTAMP

    For responses (from receiver and sender) they would go in another table `responses`

    `id` int(12) NOT NULL AUTO_INCREMENT
    `response` text NOT NULL
    `message_id` varchar(10)
    `responder_id` varchar(10)
    `date_sent` DATETIME or TIMESTAMP
    `read` int(1) for 0 - 1
    `date_read` DATETIME or TIMESTAMP

    When composing you would select the receiver (jquery.autocomplete would work well) and fill out the form containing subject and message and submit the form.
    This is added to your messages table.

    On the receiving side you query the messages table something like this (ROUGH/UNTESTED)

    Code:
    SELECT
    m.id,
    m.subject,
    m.message,
    m.date_sent,
    m.read,
    m.date_read,
    r.response,
    r.date_sent AS response_date_sent,
    r.read AS response_read,
    r.date_read AS response_date_read,
    u1.username AS creator_name,
    u2.username AS replier_name
    
    FROM messages AS m  
        LEFT JOIN responses AS r
            ON r.message_id = m.id
        LEFT JOIN users AS u1
            ON u1.id = m.sender_id    
        LEFT JOIN users AS u2
            ON u2.id = m.responder_id                
    WHERE the m.receiver_id = '$user_id'
    Now assuming this is close to working code you could use fetchALL or build a $DATA array and then use this to display info in two formats, one being a list with subject (in bold if not read) and date_sent, the other "view" would be if(isset($_GET['view'])), which would show the message thread and form where they could reply.

    Note for the if(isset($_GET['view'])) line I would also build an array of message ID's based off the $DATA array and make sure that the $_GET['view'] id is in_array($_GET['view'], $approved_message_ids) so they can only read messages sent to them. Think email inbox.

    Anyway, this should give you enough to get started on.

  13. #113
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    Goodness, you are opening a can of worms. No really this is a topic best taken up in the design form.

    I guess the basics would be to have a table `messages`

    `id` int(12) NOT NULL AUTO_INCREMENT
    `subject` varchar(65)
    `message` text NOT NULL
    `receiver_id` varchar(10)
    `sender_id` varchar(10)
    `date_sent` DATETIME or TIMESTAMP
    `read` int(1) for 0 - 1 default 0
    `date_read` DATETIME or TIMESTAMP

    For responses (from receiver and sender) they would go in another table `responses`

    `id` int(12) NOT NULL AUTO_INCREMENT
    `response` text NOT NULL
    `message_id` varchar(10)
    `responder_id` varchar(10)
    `date_sent` DATETIME or TIMESTAMP
    `read` int(1) for 0 - 1
    `date_read` DATETIME or TIMESTAMP

    When composing you would select the receiver (jquery.autocomplete would work well) and fill out the form containing subject and message and submit the form.
    This is added to your messages table.

    On the receiving side you query the messages table something like this (ROUGH/UNTESTED)

    Code:
    SELECT
    m.id,
    m.subject,
    m.message,
    m.date_sent,
    m.read,
    m.date_read,
    r.response,
    r.date_sent AS response_date_sent,
    r.read AS response_read,
    r.date_read AS response_date_read,
    u1.username AS creator_name,
    u2.username AS replier_name
    
    FROM messages AS m  
        LEFT JOIN responses AS r
            ON r.message_id = m.id
        LEFT JOIN users AS u1
            ON u1.id = m.sender_id    
        LEFT JOIN users AS u2
            ON u2.id = m.responder_id                
    WHERE the m.receiver_id = '$user_id'
    Now assuming this is close to working code you could use fetchALL or build a $DATA array and then use this to display info in two formats, one being a list with subject (in bold if not read) and date_sent, the other "view" would be if(isset($_GET['view'])), which would show the message thread and form where they could reply.

    Note for the if(isset($_GET['view'])) line I would also build an array of message ID's based off the $DATA array and make sure that the $_GET['view'] id is in_array($_GET['view'], $approved_message_ids) so they can only read messages sent to them. Think email inbox.

    Anyway, this should give you enough to get started on.
    Haha sorry and i'll try to give this a shot, I doubt i'll be able to, but i'll try haha

  14. #114
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Update on that query. Forgot you have user_id in the users table and Username for the user name.
    PHP Code:
    $sql "SELECT
    m.id,
    m.subject,
    m.message,
    m.date_sent,
    m.read,
    m.date_read,
    r.response,
    r.date_sent AS response_date_sent,
    r.read AS response_read,
    r.date_read AS response_date_read,
    u1.Username AS creator_name,
    u2.Username AS replier_name
    FROM messages AS m 
        LEFT JOIN responses AS r
            ON r.message_id = m.id 
        LEFT JOIN users AS u1
            ON u1.user_id = m.sender_id    
        LEFT JOIN users AS u2
            ON u2.user_id = r.responder_id             
    WHERE m.receiver_id = '
    $user_id'"

  15. #115
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    Update on that query. Forgot you have user_id in the users table and Username for the user name.
    PHP Code:
    $sql "SELECT
    m.id,
    m.subject,
    m.message,
    m.date_sent,
    m.read,
    m.date_read,
    r.response,
    r.date_sent AS response_date_sent,
    r.read AS response_read,
    r.date_read AS response_date_read,
    u1.Username AS creator_name,
    u2.Username AS replier_name
    FROM messages AS m 
        LEFT JOIN responses AS r
            ON r.message_id = m.id 
        LEFT JOIN users AS u1
            ON u1.user_id = m.sender_id    
        LEFT JOIN users AS u2
            ON u2.user_id = r.responder_id             
    WHERE m.receiver_id = '
    $user_id'"
    Alright, i'm back haha. So i'm working on an application and I want to approve or deny them. I have a table in my dashboard and it processes them, sends the email, updates there status to approve or unapproved, etc, but, when they get accepted, I want to insert some of there data into another table so they can login to the dashboard, but sadly its not working. Everything is working accept inserting them into the table, thats the only thing.

    Code:
    <?php
    include "../core/config.php";
    if(isset($_POST['approved']))
    {
    	$id = $_GET['id'];
    	$db->query("UPDATE tapps SET Approve = 'Approved' WHERE id = '".$id."'");
    	$query1 = $db->query("SELECT Username, Email, Skype, FName, LName, Rank FROM tapps WHERE id = '".$id."'");
    	$username = null;
    	$email = null;
    	$skype = null;
    	$fname = null;
    	$lname = null;
    	$rank = null;
    	while($row = $query1->fetch_array())
    	{
    		$username = $row['Username'];
    		$email = $row['Email'];
    		$skype = $row['Skype'];
    		$fname = $row['FName'];
    		$lname = $row['LName'];
    		$rank = $row['Rank'];
    	}
    	$db->query("INSERT INTO users (Username, Email, SkypeID, FName, LName, Rank) VALUES ('".$username."','".$email."','".$skype.",'".$fname."','".$lname."','".$rank."') WHERE id = '".$id."'");
    	$message = "Congratulations ".$username.", you have been accepted into the EliteGamingNetwork Training Program!";
    	mail($email, 'Congratulations!', $message); # Or if the message is long store it in $message = 'long message here'; and mail('email', 'Congrats', $message);
    	echo 'email sent.';
    }
    
    if(isset($_POST['unapproved']))
    {
    	$id = $_GET['id'];
    	$query = $db->query("UPDATE tapps SET Approve = 'Denied' WHERE id = '".$id."'");
    	$query1 = $db->query("SELECT Username, Email, Skype, FName, LName, Rank FROM tapps WHERE id = '".$id."'");
    	$username = null;
    	$email = null;
    	$skype = null;
    	$fname = null;
    	$lname = null;
    	$rank = null;
    	while($row = $query1->fetch_array())
    	{
    		$username = $row['Username'];
    		$email = $row['Email'];
    		$skype = $row['Skype'];
    		$fname = $row['FName'];
    		$lname = $row['LName'];
    		$rank = $row['Rank'];
    	}
    	mail($email, 'We\'re sorry', 'You have been not been approved, etc.'); # Or if the message is long store it in $message = 'long message here'; and mail('email', 'we\'re sorry.', $message);
    	echo 'email sent.';
    }
    ?>

  16. #116
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You don't quote null.

  17. #117
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    You don't quote null.
    Is that why? And its not quoted.

  18. #118
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    This is wrong. You don't have INSERT INTO and WHERE in the same query.
    PHP Code:
    $db->query("INSERT INTO users (Username, Email, SkypeID, FName, LName, Rank) VALUES ('".$username."','".$email."','".$skype.",'".$fname."','".$lname."','".$rank."') WHERE id = '".$id."'"); 
    Should be
    PHP Code:
    $db->query("INSERT INTO users (Username, Email, SkypeID, FName, LName, Rank) VALUES ('".$username."','".$email."','".$skype.",'".$fname."','".$lname."','".$rank."')"); 
    Or is it supposed to be an update?

  19. #119
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    This is wrong. You don't have INSERT INTO and WHERE in the same query.
    PHP Code:
    $db->query("INSERT INTO users (Username, Email, SkypeID, FName, LName, Rank) VALUES ('".$username."','".$email."','".$skype.",'".$fname."','".$lname."','".$rank."') WHERE id = '".$id."'"); 
    Should be
    PHP Code:
    $db->query("INSERT INTO users (Username, Email, SkypeID, FName, LName, Rank) VALUES ('".$username."','".$email."','".$skype.",'".$fname."','".$lname."','".$rank."')"); 
    Or is it supposed to be an update?
    Alright, changed it and it still doesn't work

  20. #120
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    How are you getting POST and GET in the same action? Are you defining a GET value within the <form action="" attribute? I will offer this assuming id is POST.
    PHP Code:
    <?php
    if(isset($_POST['approved']) && isset($_POST['id']))
    {
        
    $id $_POST['id'];
        
    $db->query("UPDATE tapps SET Approve = 'Approved' WHERE id = '".$id."'");
        
    $db->query("INSERT INTO users (Username, Email, SkypeID, FName, LName, Rank)
        SELECT Username, Email, Skype, FName, LName, Rank FROM tapps WHERE id = '"
    .$id."'"); 
        
    $message "Congratulations ".$username.", you have been accepted into the EliteGamingNetwork Training Program!";
        
    mail($email'Congratulations!'$message); # Or if the message is long store it in $message = 'long message here'; and mail('email', 'Congrats', $message);
        
    echo 'email sent.';
    }
    ?>

  21. #121
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    How are you getting POST and GET in the same action? Are you defining a GET value within the <form action="" attribute? I will offer this assuming id is POST.
    PHP Code:
    <?php
    if(isset($_POST['approved']) && isset($_POST['id']))
    {
        
    $id $_POST['id'];
        
    $db->query("UPDATE tapps SET Approve = 'Approved' WHERE id = '".$id."'");
        
    $db->query("INSERT INTO users (Username, Email, SkypeID, FName, LName, Rank)
        SELECT Username, Email, Skype, FName, LName, Rank FROM tapps WHERE id = '"
    .$id."'"); 
        
    $message "Congratulations ".$username.", you have been accepted into the EliteGamingNetwork Training Program!";
        
    mail($email'Congratulations!'$message); # Or if the message is long store it in $message = 'long message here'; and mail('email', 'Congrats', $message);
        
    echo 'email sent.';
    }
    ?>
    The post is for the button in the table I created and the get is to get the id of the row so I can process that application. Thats working fine, its just my insert query into another table. Thats the one i'm having trouble with, Everything else works good. Just trying to insert some of the form data into another table so I can process there account.

  22. #122
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    772
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Then assuming you can retrieve a GET value on POST, then just changing the lines where I have $_POST['id'] to $_GET['id'] should work. But if you don't see "email sent" then you're not getting past that opening condition. I would suggest you grab that GET on the page before (where the form is and add it as a hidden input so $_POST['id'] will be valid.

  23. #123
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    Then assuming you can retrieve a GET value on POST, then just changing the lines where I have $_POST['id'] to $_GET['id'] should work. But if you don't see "email sent" then you're not getting past that opening condition. I would suggest you grab that GET on the page before (where the form is and add it as a hidden input so $_POST['id'] will be valid.

    What? I'm seeing "email sent". Thats not the problem. I just don't know why the insert query isn't working. Everything else works except the insert query. It updates, it selects, it sends the email, etc, but it doesn't insert the data into the table.

  24. #124
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fredrock View Post
    What? I'm seeing "email sent". Thats not the problem. I just don't know why the insert query isn't working. Everything else works except the insert query. It updates, it selects, it sends the email, etc, but it doesn't insert the data into the table.
    Update, I got it working.

  25. #125
    SitePoint Enthusiast
    Join Date
    Feb 2014
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm back! So, I don't know if you're good with YouTube or not, but theres a site called socialblade and it gives stats on channels. Well, I have two things I want to do, but lets start with the simpler one. The first thing I want to do is get check and see if a channel meets our view requirements and for some reason I cannot use the YouTube API, it says its not setup, but it is. Anyway, so I want to use the site socialblade to get the stats, etc. Lets say, I make a form, I type in the user I want to check, I then want it to display a message and there view count and if they have a network. In the source code, this is the view count source
    Code:
    Views for the Last 30 Days: <span style = "color:#333; padding-left: 10px;">296,727,900
    And if the views have over 2,000 I want it to display a message, etc and heres the one for the network
    Code:
    <div style ="width: 770px; height: 20px; padding: 10px 15px 0px 15px; line-height: 20px; color:#999;">			
                    Networked With / Claimed By:
                                            <span style ="padding-left: 20px;"><a style ="text-decoration: none;" href ="/youtube/network/Polaris">Polaris</a></span>
                                </div><div style ="clear: both;"></div>
            </div><div style ="clear: both;"></div>
        </div>
    If the network states "none" I want it to display a message as well when I type in the form. I don't know how to do this well. I've been searching to find how to do this with cURL, but i've had no luck. If you could help that would be great, thanks in advance!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •