HI all
am working on forum and i work with functions
and i seem to have missed some thing
But i dont know where and i cant get the functions to work with inserting value in mysql!!
here is my for form file..
add-maintopic.php
<?php
require( './functions.php');
$action=$_POST["action"];
$username=$_POST["username"];
$email=$_POST["email"];
$password=$_POST["password"];
$maintopicname=$_POST["maintopicname"];
$maintopicdescription=$_POST["maintopicdescription"];
if ($action=="add_two") {
if ($username=="" or $email=="" or $password=="" or $maintopicname=="" or $maintopicdescription=="") {
showheader("All the Fields Have Not Been Filled in");
echo "You Must Fill in all fields before proceeding";
showfooter();
exit;
}
addmaintopic();
showheader("Your Post has successfully been added to the topics");
echo "Your post was added, and your post password is $password.<P>You may go back now and view it";
showfooter();
}
else {
?>
<TABLE BORDER=0 WIDTH=100% CELLSPACING=3 CELLPADDING=5>
<TR>
<TD>
<FONT COLOR="#000000" FACE="Arial,Verdana,Helvetica" size=-1>
<P>
<a href="main-topicview.php"><FONT COLOR="#000000">Return Back to Main Topics</a>
</TD>
</TR>
</TABLE>
<FORM METHOD=POST ACTION="<?php echo $PHP_SELF ?>">
<INPUT TYPE="hidden" name="action" value="add_two">
<table border=0 cellpadding=0 cellspacing=0 width="95%">
<TR><td bgcolor="#000000">
<table border=0 cellpadding=4 cellspacing=1 width=100%>
<tr bgcolor="#C0C0C0">
<td >
<FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica"><B>Main Topic Name:</B></FONT></td><td>
<INPUT TYPE="TEXT" NAME="maintopicname" SIZE=25>
</td></tr>
<tr bgcolor="#C0C0C0">
<td >
<FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica"><B>Main Creator:</B></FONT></td><td>
<INPUT TYPE="TEXT" NAME="username" SIZE=25>
</td></tr>
<tr bgcolor="#C0C0C0">
<td>
<FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica"><B>Your Email Address:</B></FONT></td>
<td><INPUT TYPE="text" NAME="email" SIZE=25 VALUE="">
</font></td></tr>
<tr bgcolor="#C0C0C0">
<td>
<FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica"><B>Your Password:</B>
<BR><FONT SIZE="-2">This is used when you would like to edit or delete your maintopic.
</FONT></td><td>
<INPUT TYPE="password" NAME="password" SIZE=25 VALUE="">
</font></td></tr>
<tr bgcolor="#C0C0C0">
<td valign=top>
<FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica"><B>Main Topic Description:</B></FONT>
<p>
<FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">
The Description appear exactly as you have submitted them an can only contane 20 Letters. HTML will not be allowed, as the tags are instantly converted into harmless text. Therefore, you cannot have HTML formatting.
</p></font>
</td>
<td>
<TEXTAREA NAME="maintopicdescription" ROWS=3 COLS=50 WRAP="VIRTUAL"></TEXTAREA></td></tr>
</table>
</td></tr></table>
<P>
<CENTER>
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit Main Topic">
<INPUT TYPE="RESET" NAME="Reset" VALUE="Clear Fields">
<br>
</CENTER>
</FORM>
<?php
}
?>
and here is the function.php i made with the functions and db conncets
<?php
include ("../Management/mysqlcondbfm.php");
}
function addmaintopic () {
global $password,$email,$username,$maintopicname,$maintopicdescription;
$timestamp = time();
$new_password = addslashes($password); $new_email = addslashes($email);
$new_name = addslashes($username);
$new_post = addslashes(htmlspecialchars($maintopicdescription)));
$insert = mysql_query("INSERT INTO mainpost VALUES ('NULL','$maintopicname','NULL','$new_name','$new_email','$new_password','$new_post','$timestamp')");
if (mysql_error() != "") {
showheader("MySQL Error ".mysql_error());
?>
<br><p><center><b>There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
exit;
}
}
?>