Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:22:54+00:00 2026-05-24T20:22:54+00:00

if (isset($submit)) { $getusers = mysql_query(SELECT * FROM register); while($getrows = mysql_fetch_array($getusers)) { $users

  • 0
if (isset($submit)) {
  $getusers = mysql_query("SELECT * FROM register");
  while($getrows = mysql_fetch_array($getusers)) {
    $users = $getrows['username'];
    if ($touser == $users) {
      echo "$users";
      $send = $_GET['send'];
      if ($send == $one) {
        $query = mysql_query(
                   "INSERT INTO mailtbl VALUES 
                    (
                      '', '$touser', '$fromuser', '$subject', 
                      '$message', '0', '0', '1', '$date', '$rand'
                    )"
                 );
        $query2 = mysql_query(
                    "INSERT INTO mailtbl_admin VALUES 
                     (
                        '', '$touser', '$fromuser', '$subject', 
                        '$message', '0', '0', '1', '$date', '$rand'
                     )"
                  ); 
        $echo = "Message successfully sent."; 
      }
    } else {
      $echo = "There is no such user with the name of '$touser'";
    }
  }
  echo "$echo";
}

I am trying to write code that accepts the message to send to another user if the recipient is in my database. The problem is that I think my condition (if ($touser == $users) is wrong. $touser refers to my $_POST['recipient'] in my form and $users refer to the users in the database.

Could someone please review my code to ensure I’m on the right track?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:22:55+00:00Added an answer on May 24, 2026 at 8:22 pm

    Instead of looping through all the users in your table, why don’t you instead add a WHERE statement in your SQL command like this:

    "SELECT * FROM register WHERE username = '" . $touser . "'"
    

    If you get results send the message. If you get no results, display the ‘no such user’ message.

    Also, if you are having trouble evaluating $touser to $user, try outputting the contents of $touser to make sure it’s what you think it is.

    print_r($touser);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if (isset($_POST['login'])) { $query = mysql_query(" SELECT id FROM users WHERE username = '".mysql_real_escape_string($_POST['username'])."'
From the isset() docs : isset() will return FALSE if testing a variable that
<?php session_start(); include(connect.php); $timeout = 60 * 30; $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); if(isset($_POST['userName']))
I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something
If the user manually clicks the 'submit' button, i use this code: if (isset($_POST['submit_findall']))
Is there a simpler function to something like this: if (isset($_POST['Submit'])) { if ($_POST['login']
For example i use this little code: <?php if (isset($_POST['Submit'])){ if ((@$_POST['Submit'] == 'x'))
At the top of my file I have PHP Code: if (!ISSET ($_POST['submit'])) which
i have this image upload script. <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = $_FILES['new_image']['name'];
Why wont this work? <?php include top.php; include connect.php; if(isset($_POST[submit])) { $error = ;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.