Jump to content
Sign in to follow this  
inadatequate

PHP invite

Recommended Posts

Sveicināti, vai nu man vairs īsti galva nestrādā vai kas. Var kāds palīdzēt šo 

 if(isset($_POST["submit3"]))
  {

    $addusername = $_POST['addusername'];
    $captain = $_POST['captain'];

    $sqlp = "SELECT * FROM `users` WHERE `username` = '$addusername'";
    $resultu = mysqli_query($con, $sqlp);
    while($row = mysqli_fetch_array($resultu))
    {
      $identi = $row['id'];

      $sqa5 = "INSERT INTO `user_invites`(`team_id`, `user_id`, `captain`) VALUES ('$ide','$identi','$captain')";

       if (mysqli_query($con,$sqa5)==TRUE){
        $error = '<div class="alert alert-success" style="margin-top:10px;" role="alert">
                                                <i class="fa fa-check" aria-hidden="true"></i> Uzaicinājums tika nosūtīts!
                                              </div>';
      }

      else {
        $error = '<div class="alert alert-danger" style="margin-top:10px;" role="alert">
                                                <i class="fa fa-check" aria-hidden="true"></i> Oops, kaut kas nenostrādāja!
                                              </div>';
      }}

 

Uztaisīt, ka, ja invits jau ir tāds tādam lietotājam nosūtīts viņš nenosūta? Var kāds izlīdzēt?

Share this post


Link to post
Share on other sites

Skaties pats, pēc kā skatīsies vai pēc team_id vai captain vai pat pēc abiem. Tikai kodā neredzēju norādītu $ide, kas tev tur ir kā team_id... skaties pats. Beigās arī trūkst }, nezinu vai tev tur kods turpinās vai esi aizmirsis nokopēt no īstā koda klāt.

if (isset($_POST["submit3"]))
{
	$addusername = $_POST['addusername'];
	$captain = $_POST['captain'];
	$sqlp = "SELECT * FROM `users` WHERE `username` = '$addusername'";
	$resultu = mysqli_query($con, $sqlp);
	while ($row = mysqli_fetch_array($resultu))
	{
		$identi = $row['id'];
		$isql = "SELECT `user_id` FROM `user_invites` WHERE `user_id`='$identi' and `team_id`='$ide' LIMIT 1"; // neredzu $ide norādītu kodā...
		$iquery = mysqli_query($con, $isql);
		if (mysqli_num_rows($iquery) == 0)
		{
			$sqa5 = "INSERT INTO `user_invites`(`team_id`, `user_id`, `captain`) VALUES ('$ide','$identi','$captain')";
			if (mysqli_query($con, $sqa5) == TRUE)
			{
				$error = '<div class="alert alert-success" style="margin-top:10px;" role="alert">
                                                  <i class="fa fa-check" aria-hidden="true"></i> Uzaicinājums tika nosūtīts!
                                                </div>';
			}
			else
			{
				$error = '<div class="alert alert-danger" style="margin-top:10px;" role="alert">
                                                  <i class="fa fa-check" aria-hidden="true"></i> Oops, kaut kas nenostrādāja!
                                                </div>';
			}
		}
		else
		{
			$error = '<div class="alert alert-danger" style="margin-top:10px;" role="alert">
                                                <i class="fa fa-check" aria-hidden="true"></i> Jūs jau esat nosūtījis uzaicinājumu!
                                              </div>';
		}
	}

 

  • Upvote 1

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.