een form naar de zelfde pagina laten gaan
Het form zou er zo moeten uitzien:
<form methode="POST" action=" ZIE VRAAG! ">
Author:<br>
<input type="text" name="commentwriter" size="60"><br>
Message:<br>
<textarea name="content" rows="10" cols="60"> </textarea><br>
<input type="submit" name="submit" value="Submit" size="20">
</form>
De hele php-code van de pagina:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?
require('config.php');
if (!@mysql_select_db("$db_database", @mysql_connect("$db_host", "$db_username", "$db_password")))
{
echo 'Er kan geen database connectie gemaakt worden.';
exit();
}
if((!$_REQUEST['newsid']) && (!$_REQUEST['readmore'])){
$sql = "SELECT * FROM news WHERE visible = 1 order by newsid DESC";
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1){
while ($row = mysql_fetch_array ($res)){
echo'
<table border="0" cellspacing="0" cellpadding="5" id="phpnieuws_inside" width="430">
<tr>
<td width="430" id="title">
<font face="Verdana" size="2"><b>' . $row['newstitle'] . '</b></font><br>
<i><font face="Verdana" size="1">By: ' . $row['newswriter'] . '</font></i>
</td>
</tr>
<tr>
<td width="430" id="news_short">
<font face="Verdana" size="2">' . $row['news_short'] . '</font>
</td>
</tr>
<tr>
<td width="430" id="comments">
<p align="right"><font face="Verdana" size="2">|<a href="index.php?newsid=' . $row['newsid'] . '&readmore=1" style="text-decoration: none">Read More</a></font></p>
</td>
</tr>
</table><br><br>';
}
}
} else {
$newsid = $_REQUEST['newsid'];
$sql = 'SELECT * FROM news WHERE newsid = \''.$newsid.'\'';
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1){
while ($row = mysql_fetch_array ($res)){
echo'
<table border="0" cellspacing="0" cellpadding="5" id="phpnieuws_inside" width="430">
<tr>
<td width="430" id="title">
<font face="Verdana" size="2"><b>' . $row['newstitle'] . '</b></font><br>
<i><font face="Verdana" size="1">By: ' . $row['newswriter'] . '</font></i>
</td>
</tr>
<tr>
<td width="430" id="news_short">
<font face="Verdana" size="2" color="#9E9E9E"><i>' . $row['news_short'] . '</i></font>
</td>
</tr>
<tr>
<td width="430" id="news_short">
<font face="Verdana" size="2">' . $row['news_long'] . '</font>
</td>
</tr>
</table><br><br>
<img src="images/commentline.gif" border="0">';
}
}
$newsid=$_GET[newsid];
$mysql_id = mysql_connect("$db_host", "$db_username", "$db_password");
mysql_select_db("$db_database",$mysql_id);
$sql="SELECT * FROM comments WHERE newsid='$newsid'";
$res = mysql_query("$sql", $mysql_id);
$row = mysql_fetch_row($res);
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1)
{
while ($row = mysql_fetch_array ($res))
{
echo'
<table border="0" cellspacing="0" cellpadding="0" id="comments" width="430">
<tr>
<td width="5" bgcolor="#D2D2D2">
</td>
<td width="425" id="name" bgcolor="#D2D2D2" height="10" valgin="top">
<font face="Verdana" size="2">By <u>' . $row['commentwriter'] . '</u></font>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="3" id="commentstext" width="430">
<tr>
<td width="430" id="text">
<font face="Verdana" size="2">' . $row['commenttext'] . '</font>
</td>
</tr>
</table>
<br><br>
<p align="center"><a href="postcomment.php?newsid=' . $row['newsid'] . '" style="text-decoration: none"><font face="Verdana" size="2" color="#000000"><u>Post Comment</u></font></a></p>';}}
else {
echo '<table border="0" cellspacing="0" cellpadding="5" id="nocomment" height="10" width="430">
<tr>
<td width="430">
<font face="Verdana" size="2" color="#000000">No comments on this item yet!</font>
</td>
</tr>
</table>
<p align="center"><a href="postcomment.php?newsid='.$newsid.'" style="text-decoration: none"><font face="Verdana" size="2" color="#000000"><u>Post Comment</u></font></a></p>';
}
}
?>
require('config.php');
if (!@mysql_select_db("$db_database", @mysql_connect("$db_host", "$db_username", "$db_password")))
{
echo 'Er kan geen database connectie gemaakt worden.';
exit();
}
if((!$_REQUEST['newsid']) && (!$_REQUEST['readmore'])){
$sql = "SELECT * FROM news WHERE visible = 1 order by newsid DESC";
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1){
while ($row = mysql_fetch_array ($res)){
echo'
<table border="0" cellspacing="0" cellpadding="5" id="phpnieuws_inside" width="430">
<tr>
<td width="430" id="title">
<font face="Verdana" size="2"><b>' . $row['newstitle'] . '</b></font><br>
<i><font face="Verdana" size="1">By: ' . $row['newswriter'] . '</font></i>
</td>
</tr>
<tr>
<td width="430" id="news_short">
<font face="Verdana" size="2">' . $row['news_short'] . '</font>
</td>
</tr>
<tr>
<td width="430" id="comments">
<p align="right"><font face="Verdana" size="2">|<a href="index.php?newsid=' . $row['newsid'] . '&readmore=1" style="text-decoration: none">Read More</a></font></p>
</td>
</tr>
</table><br><br>';
}
}
} else {
$newsid = $_REQUEST['newsid'];
$sql = 'SELECT * FROM news WHERE newsid = \''.$newsid.'\'';
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1){
while ($row = mysql_fetch_array ($res)){
echo'
<table border="0" cellspacing="0" cellpadding="5" id="phpnieuws_inside" width="430">
<tr>
<td width="430" id="title">
<font face="Verdana" size="2"><b>' . $row['newstitle'] . '</b></font><br>
<i><font face="Verdana" size="1">By: ' . $row['newswriter'] . '</font></i>
</td>
</tr>
<tr>
<td width="430" id="news_short">
<font face="Verdana" size="2" color="#9E9E9E"><i>' . $row['news_short'] . '</i></font>
</td>
</tr>
<tr>
<td width="430" id="news_short">
<font face="Verdana" size="2">' . $row['news_long'] . '</font>
</td>
</tr>
</table><br><br>
<img src="images/commentline.gif" border="0">';
}
}
$newsid=$_GET[newsid];
$mysql_id = mysql_connect("$db_host", "$db_username", "$db_password");
mysql_select_db("$db_database",$mysql_id);
$sql="SELECT * FROM comments WHERE newsid='$newsid'";
$res = mysql_query("$sql", $mysql_id);
$row = mysql_fetch_row($res);
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1)
{
while ($row = mysql_fetch_array ($res))
{
echo'
<table border="0" cellspacing="0" cellpadding="0" id="comments" width="430">
<tr>
<td width="5" bgcolor="#D2D2D2">
</td>
<td width="425" id="name" bgcolor="#D2D2D2" height="10" valgin="top">
<font face="Verdana" size="2">By <u>' . $row['commentwriter'] . '</u></font>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="3" id="commentstext" width="430">
<tr>
<td width="430" id="text">
<font face="Verdana" size="2">' . $row['commenttext'] . '</font>
</td>
</tr>
</table>
<br><br>
<p align="center"><a href="postcomment.php?newsid=' . $row['newsid'] . '" style="text-decoration: none"><font face="Verdana" size="2" color="#000000"><u>Post Comment</u></font></a></p>';}}
else {
echo '<table border="0" cellspacing="0" cellpadding="5" id="nocomment" height="10" width="430">
<tr>
<td width="430">
<font face="Verdana" size="2" color="#000000">No comments on this item yet!</font>
</td>
</tr>
</table>
<p align="center"><a href="postcomment.php?newsid='.$newsid.'" style="text-decoration: none"><font face="Verdana" size="2" color="#000000"><u>Post Comment</u></font></a></p>';
}
}
?>
Dat form zou op de 2 plaatsen moeten komen waar de link "postcomment.php?newsid='.$newsid.'" als "Post Comment" beschreven staat.
Hoe kan ik dit doen?
Kan iemand aub hier een stukje code met dat form en dan de verwerking en verdere afloop ervan posten?
Mvg. Jens
Gewijzigd op 01/01/1970 01:00:00 door Jens V
dubbel