Hej, siedzę nad tym dobę i nie potrafię znaleźć rozwiązania.
Po kliknięciu wysłania formularza nic mi się nie dzieje, przeładowuje się strona tylko.
Proszę o pomoc, podpowiedź, dlaczego to nie trafia do bazy. Inbox i users to są tabele.
<?php
session_start();
require_once('config.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="#" rel="stylesheet" title="Style" />
<title>New PM</title>
</head>
<body>
<div class="header">
<a href="<?php echo $url_home; ?>"><img src="" alt="Members Area" /></a>
</div>
<?php
if(isset($_SESSION['user']))
{
$form = true;
if(isset($_POST['sendPm']))
{
$otitle = $_POST['title'];
$orecip = $_POST['recip'];
$omessage = $_POST['message'];;
if(isset($_POST['sendPm']))
{
$sql = "select count(id) as recip, id as recipid, (select count(*) from inbox) as npm from users where nick='$orecip'";
$result = $connection->query($sql);
if(!$result) throw new Exception($connection->error);
if($result->num_rows>0)
{
while ($row = mysqli_fetch_array($result))
{
$recipid = $row['recipid'];
if($recipid!=$_SESSION['user'])
{
while ($row = mysqli_fetch_array($result))
{
$id = $result['npm']+1;
$userSession = $_SESSION['user'];
$resultRecipid = $result['recipid'];
$sql = "insert into inbox (id, id2, title, user1, user2, message, timestamp, user1read, user2read)values('$id', 1, '$title', '$userSession', '$resultRecipid', '$message', time(), 'yes', 'no')";
$resul2 = $connection->query($sql);
if(!$result2) throw new Exception($connection->error);
if($result2)
{
?>
<div class="message">The message has successfully been sent.<br />
<a href="list.php">List of my Personal messages</a></div>
<?php
$form = false;
}
else
{
$error = 'An error occurred while sending the message';
}
}
}
else
{
$error = 'You cannot send a message to yourself.';
}
}
}
else
{
$error = 'The recipient does not exists.';
}
}
else
$error = 'A field is empty. Please fill of the fields.';
}
}
elseif(isset($_GET['recip']))
$orecip = $_GET['recip'];
}
if($form)
{
if(isset($error))
{
echo '<div class="message">'.$error.'</div>';
}
?>
<div class="content">
<h1>New Personal Message</h1>
<form action="send.php" method="post">
Please fill the following form to send a Personal message.<br />
<label for="title">Title</label><input type="text" value="<?php echo htmlentities($otitle, ENT_QUOTES, 'UTF-8'); ?>" id="title" name="title" /><br />
<label for="recip">Recipient<span class="small">(Username)</span></label><input type="text" value="<?php echo htmlentities($orecip, ENT_QUOTES, 'UTF-8'); ?>" id="recip" name="recip" /><br />
<label for="message">Message</label><textarea cols="40" rows="5" id="message" name="message"><?php echo htmlentities($omessage, ENT_QUOTES, 'UTF-8'); ?></textarea><br />
<input type="submit" value="Send" name="sendPm" />
</form>
</div>
<?php
}
else
{
echo '<div class="message">You must be logged to access this page.</div>';
}
?>
<div class="foot"><a href="list.php">Go to my Personal messages</a> - <a href="#">XX</a></div>
</body>
</html>