i am having a problem inserting data into mysql database.
I have the user set up to full permissions at the moment while testing,
I am able to select from the database to populate fields but can not insert, i have got the sql and the syntax is correct.
the code below is what im using... any help would relaly be apprecuated
I include the database connection in a separate file
Thanks in advance
Code: Select all
<html>
<head>
<title>Klublust UK - Content Control Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body STYLE="background-color: #E0E0E0;">
<TABLE WIDTH="600" BORDER="0" ALIGN="center" STYLE="border: 1px solid #000000; background-color: #ffffff;">
<tr>
<td><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Klublust
UK - Content Control Panel</strong></font> </div></td>
</tr>
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<div align="center">
<p><a href="index.php">Main Menu</a> - Moderators
</p>
<P><A HREF="addmod.php">Add a Moderator</A> -
<A HREF="removemod.php">Remove a Moderator</A> -
<A HREF="editmod.php">Edit a Moderator</A>
<hr width="100%" noshade COLOR="#000000" SIZE="1">
</div>
</font></td>
</tr>
<tr>
<td><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<?php
if ($_POST['submit']) {
$formfullname = $_POST['fullname'];
$formusername = $_POST['username'];
$formpassword = $_POST['txtPassword'];
$formaccessrights = $_POST['accessrights'];
if ($formfullname == "") {
echo "<strong>Please enter their full name<br></strong>";
}
else If ($formusername == "") {
echo "<strong>Please enter their username<br></strong>";
}
else if ($formpassword == "") {
echo "<strong>Please enter the password<br></strong>";
}
else if ($formaccessrights == "") {
echo "<strong>Please select some access rights<br></strong>";
}
else
{
$query = "insert into users (username,fullname,password) values ('" . $formusername . "', '" . $formfullname . "', '" . $formpassword . "')";
$result = mysql_query($query);
if ($result){
echo "Data was added to the database";
}
else {
echo "ERROR - There was a problem writing to the database<br><br>";
echo "Query Data: <strong>" . $query . "</strong><br><br><a href='index.php'>return to main menu</a>";
}
}
}
?>
<FORM ACTION="addmod.php" method="post" enctype="multipart/form-data">
<TABLE ALIGN="center" WIDTH="400" CELLSPACING="0" CELLPADDING="2" BORDER="0">
<TR>
<TD WIDTH="200">Full Name:</TD>
<TD WIDTH="200"><INPUT TYPE="text" name="fullname" value="<?echo $formfullname?>"></TD>
</TR>
<TR>
<TD>User Name:</TD>
<TD><INPUT TYPE="text" name="username" value="<?echo $formusername?>"></TD>
</TR>
<TR>
<TD>Password:</TD>
<TD><INPUT TYPE="password" name="txtPassword" value="<?echo $formpassword ?>"></TD>
</TR>
<TR>
<TD VALIGN="top">Access Rights:</TD>
<TD><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<?php
include '../config.php';
$query = "select * from Accessrights order by Accessright";
$result = mysql_query($query);
$i=0;
while ($row = mysql_fetch_row($result)){
$i=1;
echo "<INPUT TYPE='checkbox' name='accessrights' VALUE='" . $row[$sql_access_id] . "'>" . $row[$sql_access_name] . "<BR>";
}
if($i==0){ echo "NO RESULTS"; }
?>
</TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="center"><BR>
<BR><INPUT TYPE="submit" VALUE="Submit" name="submit"></TD>
</TR>
</TABLE>
<BR>
<BR>
<BR>
</FORM>
</font> </div></td>
</tr>
</table>
</body>
</html>feyd | switched to
Code: Select all
tags :: [/color][url=http://forums.devnetwork.net/viewtopic.php?t=21171][color=red]:arrow: [u][b]Posting Code in the Forums[/b][/u][/color][/url]