PHP interesse |
|
Hallo,
Ik heb 2 formulieren in 1 pagina staan.
1 formulier werkt wel maar de andere niet.
Code verwerking die het wel doet:
if($_POST['submit'] && $_POST['status']){
$user_id = $_POST['user_id'];
$status = $_POST['status'];
$war_id = $_POST['war_id'];
$sql = "INSERT INTO wars_inschrijven (user_id, status, war_id) VALUES ('".$user_id."', '".$status."', '".$war_id."')";
mysql_query($sql);
}
if($_POST['submit'] && $_POST['status']){ $user_id = $_POST['user_id']; $status = $_POST['status']; $war_id = $_POST['war_id']; $sql = "INSERT INTO wars_inschrijven (user_id, status, war_id) VALUES ('".$user_id."', '".$status."', '".$war_id."')"; }
code verwerking die het niet doet:
if($_POST['submit2'] && $_POST['text']){
$posted_by = $_POST['posted_by'];
$text = $_POST['text'];
$warid = $_POST['warid'];
$sql = "INSERT INTO wars_reactie (posted_by, text, warid) VALUES ('".$posted_by."', '".$text."', '".$warid."')";
mysql_query($sql);
}
if($_POST['submit2'] && $_POST['text']){ $posted_by = $_POST['posted_by']; $text = $_POST['text']; $warid = $_POST['warid']; $sql = "INSERT INTO wars_reactie (posted_by, text, warid) VALUES ('".$posted_by."', '".$text."', '".$warid."')"; }
code niet werkende form
echo "<form method=post acion=".$PHP_SELF."><center><textarea cols=40 rows=5 name=text></textarea><input type=hidden value=".$userdata['user_id']." name=posted_by><input type=hidden value=".$id." name=warid><br /><input type=submit value=Post reactie! name=submit2></center></form><br />";
echo "<form method=post acion=".$PHP_SELF."><center><textarea cols=40 rows=5 name=text></textarea><input type=hidden value=".$userdata['user_id']." name=posted_by><input type=hidden value=".$id." name=warid><br /><input type=submit value=Post reactie! name=submit2></center></form><br />";
code werkende form:
echo "<form method=post action=".$PHP_SELF.">";
echo "<tr><td width=125>Kom je?</td><td>";
echo "<select name=\"status\">
<option value=\"Ja!\">Ja</option>
<option value=\"Misschien\">Misschien</option>
<option value=\"Nee\">Nee</option>
</select>";
echo "<input type=hidden name=user_id value=".$userdata['user_id']."><input type=hidden name=war_id value=".$id."></td></tr>";
echo "<tr><td width=125> </td><td><input type=submit name=submit value=Oke></form></td></tr>";
echo "<form method=post action=".$PHP_SELF.">"; echo "<tr><td width=125>Kom je?</td><td>"; echo "<select name=\"status\"> <option value=\"Ja!\">Ja</option> <option value=\"Misschien\">Misschien</option> <option value=\"Nee\">Nee</option> </select>"; echo "<input type=hidden name=user_id value=".$userdata['user_id']."><input type=hidden name=war_id value=".$id."></td></tr>"; echo "<tr><td width=125> </td><td><input type=submit name=submit value=Oke></form></td></tr>";
Alvast bedankt voor de help!
|