Forum (alweer)

Gestart doorBremdecoolste27 reacties95 weergaven

28 berichten · pagina 1 van 2

Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

Ik heb weer een nieuwe vraag, Ik heb nu het forum (zonder layout dan), maar daar heb ik eventjes ingesteld dat je je email en naam moet invullen, alleen ik wil dat dat automatisch gaat, via een login systeem. Maar dan wil ik ook dat ik inlog op de website, en dat ik dan zo naar het forum kan gaan, een post maken, en dat je nog steeds ingelogd bent.... Dus niet zoals GHED (bah, wálgelijk biggrin), dat je geen apart nieuw acount moet aanmaken. maar dat je gewoon op de site registreerd en je kan op mijn forum.... eigenlijk net zoals hier.
ik kan wel ff de codes plaatsen:

View_topic.php:
Spoiler tonen
[COLOR= #0000BB]<?php

$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Host name [/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql username [/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql password [/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Database name [/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"forum_question"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Table name 

// Connect to server and select database.[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot connect"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot select DB"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #FF8000]// get value of id that sent from address bar [/COLOR]
[COLOR= #0000BB]$id[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"SELECT * FROM $tbl_name WHERE id=$id"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$rows[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
?>

<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#F8F7F1"><strong>[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]topic[/COLOR][COLOR= #007700]];[/COLOR] ?></strong></td>
</tr>

<tr>
<td bgcolor="#F8F7F1">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]detail[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
</tr>

<tr>
<td bgcolor="#F8F7F1"><strong>By :</strong> [COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]];[/COLOR] ?> <strong>Email : </strong>[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]];[/COLOR]?></td>
</tr>
main_topic:
Spoiler tonen
[COLOR= #0000BB]<?php

$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Host name [/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql username [/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql password [/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Database name [/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"forum_question"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Table name 

// Connect to server and select database.[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot connect"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot select DB"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"SELECT * FROM $tbl_name ORDER BY id DESC"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// OREDER BY id DESC is order result by descending[/COLOR]

[COLOR= #0000BB]$result[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
?>

<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
<td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
</tr>

[COLOR= #0000BB]<?php[/COLOR]
 
[COLOR= #FF8000]// Start looping table row[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rows[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])){[/COLOR]
?>
<tr>
<td bgcolor="#FFFFFF">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
<td bgcolor="#FFFFFF"><a href="view_topic.php?id=[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR] ?>">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]topic[/COLOR][COLOR= #007700]];[/COLOR] ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]view[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
<td align="center" bgcolor="#FFFFFF">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reply[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
<td align="center" bgcolor="#FFFFFF">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]datetime[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
</tr>

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// Exit looping and close connection [/COLOR]
[COLOR= #007700]}[/COLOR]
[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]();[/COLOR]
?>

<tr>
<td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td>
</tr>
</table>
create_topic:
Spoiler tonen
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form id="form1" name="form1" method="post" action="add_topic.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3" bgcolor="#E6E6E6"><strong>Create New Topic</strong> </td>
</tr>
<tr>
<td width="14%"><strong>Topic</strong></td>
<td width="2%">:</td>
<td width="84%"><input name="topic" type="text" id="topic" size="50" /></td>
</tr>
<tr>
<td valign="top"><strong>Detail</strong></td>
<td valign="top">:</td>
<td><textarea name="detail" cols="50" rows="3" id="detail"></textarea></td>
</tr>
<tr>
<td><strong>Name</strong></td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50" /></td>
</tr>
<tr>
<td><strong>Email</strong></td>
<td>:</td>
<td><input name="email" type="text" id="email" size="50" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
add_topic:
Spoiler tonen
[COLOR= #0000BB]<?php

$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Host name [/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql username [/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql password [/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Database name [/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"forum_question"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Table name 

// Connect to server and select database.[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot connect"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot select DB"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #FF8000]// get data that sent from form [/COLOR]
[COLOR= #0000BB]$topic[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]topic[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$detail[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]detail[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$email[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #0000BB]$datetime[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"d/m/y h:i:s"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//create date time[/COLOR]

[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES($topic, $detail, $name, $email, $datetime)"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Successful<BR>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=main_forum.php>View your topic</a>"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"ERROR"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]();[/COLOR]
?>
add_answer:
Spoiler tonen
[COLOR= #0000BB]<?php

$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Host name [/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql username [/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql password [/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Database name [/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"forum_question"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Table name 

// Connect to server and select database.[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot connect"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot select DB"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #FF8000]// Get value of id that sent from hidden field [/COLOR]
[COLOR= #0000BB]$id[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #FF8000]// Find highest answer number. [/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"SELECT MAX(a_id) AS Maxa_id FROM $tbl_name WHERE question_id=$id"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$rows[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #FF8000]// add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1 [/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$rows[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$Max_id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Maxa_id[/COLOR][COLOR= #007700]]+[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$Max_id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];
}[/COLOR]

[COLOR= #FF8000]// get values that sent from form [/COLOR]
[COLOR= #0000BB]$a_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]a_name[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$a_email[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]a_email[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$a_answer[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]a_answer[/COLOR][COLOR= #007700]];[/COLOR] 

[COLOR= #0000BB]$datetime[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"d/m/y H:i:s"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]// create date and time

// Insert answer [/COLOR]
[COLOR= #0000BB]$sql2[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"INSERT INTO $tbl_name(question_id, a_id, a_name, a_email, a_answer, a_datetime)VALUES($id, $Max_id, $a_name, $a_email, $a_answer, $datetime)"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result2[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql2[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result2[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Successful<BR>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=view_topic.php?id="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">View your answer</a>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]// If added new answer, add value +1 in reply column [/COLOR]
[COLOR= #0000BB]$tbl_name2[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"forum_question"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$sql3[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"UPDATE $tbl_name2 SET reply=$Max_id WHERE id=$id"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result3[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql3[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"ERROR"[/COLOR][COLOR= #007700];
}[/COLOR]

[COLOR= #FF8000]// Close connection[/COLOR]
[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]();[/COLOR]
?>
link: http://jail.comyr.com/Forum/main_topic.php

Ik hoop dat iemand me kan helpen!

Groet, Bram.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Waarom houd je niet alles in een topic? Je had het er makkelijk bij kunnen plaatsen...

Je moet een compleet leden systeem maken, waar mensen zich kunnen aanmelden.

Als ze inloggen maken ze een sessie (waar de userid instaat), die controleer je op het forum, ze Jin dan ingelogd.

Je haalt de informatie op dmv een query en de userid die in de sessie staat en hey presto, je hebt de gegevens van de user.

Vergeet niet het forum aan te pasasen
0
Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sevvlor schreef:
Waarom houd je niet alles in een topic? Je had het er makkelijk bij kunnen plaatsen...
Je moet een compleet leden systeem maken, waar mensen zich kunnen aanmelden.

Als ze inloggen maken ze een sessie (waar de userid instaat), die controleer je op het forum, ze Jin dan ingelogd.

Je haalt de informatie op dmv een query en de userid die in de sessie staat en hey presto, je hebt de gegevens van de user.

Vergeet niet het forum aan te pasasen
Sorry, maar ik zal het toevoegen.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En een goede tip. In je forum is nu SQL-injection mogelijk, waardoor je gehacked kan worden.
Gebruik mysql_real_escape_string() op je POST/GET/COOKIE variabelen binnen je query.
0
Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waar en hoe?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Wat heb je al geprobeerd om infomatie over mysql_real_escape_string te verschaffen :? :? :?

Sorry hoor, maar dit is zooo makkelijk te vinden.
0
Berichten
916
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
waarom maak je niet 1 bestand met je database gegevens en die verbinden met alle bestanden sadley?
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
XSS Injectie mogelijk -> gebruik htmlentities();
0
Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nou, ik weet eerlijk gezegd niet precies hoe dat moet confused, het aan elkaar verbinden dan.... maar dit is alleen een test uitgave... en trouwens, ik heb nog een bug, probeer maar eens een reply te mkaen op "Test" en weet iemand hoe je het moet indelen in vakken, zoals: Aanbiedingen en Prijsvragen & Contest.... Wat is een XSS injectie?

toevoeging op 24 september 2012, 17:33:42:
En waar, in welk bestand? allemaal?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Bvanhaaren schreef:
Nou, ik weet eerlijk gezegd niet precies hoe dat moet confused, het aan elkaar verbinden dan.... maar dit is alleen een test uitgave... en trouwens, ik heb nog een bug, probeer maar eens een reply te mkaen op "Test" en weet iemand hoe je het moet indelen in vakken, zoals: Aanbiedingen en Prijsvragen & Contest.... Wat is een XSS injectie?
toevoeging op 24 september 2012, 17:33:42:
En waar, in welk bestand? allemaal?

http://nl.wikipedia.org/wiki/Cross-site_scripting

echt GOOGLEN mag wel
0
Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
oke, ik dacht dat dat verboden was? biggrin
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$input[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"<script>alert(dit is een alert);</script>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]// Zonder htmlentities:[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$input[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// output: een alert met dit is een alert
// met htmlentities[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$input[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]// output: een tekst met: <script>alert(dit is een alert);</script> en GEEN ALERT[/COLOR]
?>


toevoeging op 24 september 2012, 17:52:00:
Doe trouwens dit:

[COLOR= #0000BB]<?php
$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Host name [/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql username [/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql password [/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Database name [/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"forum_question"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Table name 

// Connect to server and select database.[/COLOR]
[COLOR= #0000BB]$connectie[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$password[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$connectie[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Geen verbinding met MySQL server![/COLOR][COLOR= #007700];
}[/COLOR]
[COLOR= #0000BB]$database[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$database[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Kan database niet vinden[/COLOR][COLOR= #007700];
}[/COLOR]
?>


i.p.v

[COLOR= #0000BB]<?php
$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Host name [/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql username [/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql password [/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Database name [/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"forum_question"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Table name 

// Connect to server and select database.[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"mysql6.000webhost.com"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"a6671097_bram"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot connect"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"a6671097_forum"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot select DB"[/COLOR][COLOR= #007700]);[/COLOR]

?>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Bvanhaaren schreef:
Nou, ik weet eerlijk gezegd niet precies hoe dat moet confused,
include....
0
Bremdecoolste

Lid · Topicstarter

Berichten
1.783
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Yeah yeah! Nu hoef je geen naam of eMail meer in te vullen! Nu nog verbeteren, met dingen als: Edit, Quote, en allereerst nog een leden systeem.... Voor PM enzo....
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Lekker bouwen. Je kan ook MultiSess gebruiken. Heb ik ook in mijn site gebouwd for years ago....
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren