Welcome to www.HAS.lv - programmējam HTML.

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
inadatequate

PHP invite

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?

0

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>';
		}
	}

 

1

Share this post


Link to post
Share on other sites

Man bija tas noslēdzošais, vienkārši nebija nokopējies. Viss darbojas, paldies. Un bija man nodefinēts iepriekš

0

Share this post


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