That’s how I’m new in here on the website so it would be super if you’ll tell if I need to do something because I am very new in here ..
What I have problem with my website it’s header and yes a second error that I do not get to go up in some manner whatsoever.
that’s how I’m going to build my own forum since I do not really bother to spend phpbbforum or what it says and. This is how I try lie same html with php code and it works not at all in some way.
i have try so here:
<form action="#" method="post">
<?php
if($stmt = $mysqli->prepare("INSERT INTO `forum_traede` (`kategori_id`, `titel`, `bruger_id`, `dato`, `tekst`) VALUES (?, ?, ?, NOW(), ?)"))
{
$stmt->bind_param('ssss', $kategori, $titel, $bruger_id, $tekst);
$kategori = $_POST["kategori"];
$titel = $_POST["titel"];
$bruger_id = $_SESSION["user_id"];
$tekst = $_POST["tekst_2"];
$stmt->execute();
$stmt->close();
header ('Location: ./bruger-forum');
}
else
{
echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
}
?>
<table border="0">
<tr>
<td id="tb-w_a"><p>Titel</p></td>
<td>:</td>
<td><input type="text" name="titel"></td>
</tr>
<tr>
<td id="tb-w_a"><p>Kategori</p></td>
<td>:</td>
<td>
<select name="kategori">
<?php
$query = "SELECT id, beskrivelse FROM forum_kategorier";
$result = $mysqli->query($query);
while(list($id_katogori, $beskrivelse) = $result->fetch_row())
{
echo "<option value=\"$id_katogori\">$beskrivelse</option>";
}
?>
</select>
</td>
</tr>
</table>
<textarea name="tekst_2" style="width:500px; height:170px;"></textarea><br />
<input type="submit" value="Opret indhold" name="godkendt_indhold">
</form>
but here I did not click the submit button
errors are here
Warning: Cannot modify header information – headers already sent by (output started at /home/jesperbo/public_html/xx.dk/bruger_forum_opretindhold.php:26) in /home/jesperbo/public_html/xx.dk/bruger_forum_opretindhold.php on line 50
I’ve also try to do it this way but there is therefore also error out.
i try here agani 🙂
<form action="http://xxx.dk/bruger-forum-godkendt/" method="post">
<table border="0">
<tr>
<td id="tb-w_a"><p>Titel</p></td>
<td>:</td>
<td><input type="text" name="titel"></td>
</tr>
<tr>
<td id="tb-w_a"><p>Kategori</p></td>
<td>:</td>
<td>
<select name="kategori">
<?php
$query = "SELECT id, beskrivelse FROM forum_kategorier";
$result = $mysqli->query($query);
while(list($id_katogori, $beskrivelse) = $result->fetch_row())
{
echo "<option value=\"$id_katogori\">$beskrivelse</option>";
}
?>
</select>
</td>
</tr>
</table>
<textarea name="tekst_2" style="width:500px; height:170px;"></textarea><br />
<input type="submit" value="Opret indhold" name="godkendt_indhold">
</form>
send infomation on here to
<?php
if($stmt = $mysqli->prepare("INSERT INTO `forum_traede` (`kategori_id`, `titel`, `bruger_id`, `dato`, `tekst`) VALUES (?, ?, ?, NOW(), ?)"))
{
$stmt->bind_param('ssss', $kategori, $titel, $bruger_id, $tekst);
$kategori = $_POST["kategori"];
$titel = $_POST["titel"];
$bruger_id = $_SESSION["user_id"];
$tekst = $_POST["tekst_2"];
$stmt->execute();
$stmt->close();
header ('Location: ../bruger-forum');
}
else
{
echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
}
?>
errors here!
Fatal error: Call to a member function prepare() on a non-object in /home/jesperbo/public_html/xxx.dk/bruger_forum_opretindhold_godkendt.php on line 2
and i have try
header ('Location: http://xxx.dk/bruger-forum/');
and
header ('Location: ../bruger-forum');
The first thing I show up to you I want out when it has sent infomation to the database then it should just “jump” back to the forum page .. I build my url up. htaccess
Feel free to ask if there is anything but as I said I come from Denmark and is not exactly the best of English
Thanks for you look!!
the error is that you are triying to set a header after sending some input to the browser.
if you want to redirect you can either move your code to the begining and send the
header('location:...);BEFORE anything.or use something like
echo "<script>window.location = 'yourURL'</script>"and the fatal error, its because your object is not being created.