LordGarfield
IS-IT--Management
Hi all,
I post my source code here
This one works.
********user_i.php*********************
<html>
<body>
<table>
<form method="post" action="user_o.php">
<tr>
<td>GEBRUIKERSNAAM:</td><td><input type="text" name="unaam"></td>
</tr>
<tr>
<td>NAAM:</td><td><input type="text" name="anaam"></td>
</tr>
<tr>
<td>VOORNAAM:</td><td><input type="text" name="vnaam"></td>
</tr>
<tr>
<td>PASWOORD:</td><td><input type="password" name="paswoord"></td>
</tr>
<tr>
<td>PASWOORD NOGMAALS:</td><td><input type="password" name="paswoordc"></td>
</tr>
<tr>
<td colspan=2>IS LID VAN</td>
</tr>
<?php
$con = mysql_connect("localhost", "root", ""
;
mysql_select_db("rcomdb"
;
$rec = mysql_query("select * from groups"
;
$i=1;
while (list($id, $gnaam) = mysql_fetch_row($rec))
{
echo "<tr><td>" . $gnaam . "</td><td><input type='checkbox' name='groep[]' value='" . $id . "'></td></tr>";
$i=$i + 1;
}
?>
<tr>
<td>
<input type="submit" name="Submit" value="Toevoegen">
</td>
</tr>
</form>
</table>
</body>
</html>
****************end user_i.php***********************
This one has the error's
***************user_o.php**********************
<?php
$unaam = $_POST['unaam'];
$paswoord = $_POST['paswoord'];
$paswoordc = $_POST['paswoordc'];
$anaam = $_POST['anaam'];
$vnaam = $_POST['vnaam'];
echo $unaam . $paswoord . $anaam . $vnaam;
if ($unaam <> '' && $paswoord <> '' && $anaam <> '' && $vnaam <> '')
{
if ($paswoord == $paswoordc)
{
$db = mysql_connect("localhost","root",""
;
mysql_select_db ("rcomdb"
;
$sql = "select usern from users where usern = ". $unaam;
$result1 = mysql_query($sql);
if (mysql_num_rows($result1)>0)
{
echo 'Gebruiker bestaat reeds';
}
else
{
$sql = "insert into users (usern, userp, naam, vnaam) values (" .$unaam. "," .$paswoord. "," .$anaam. "," .$vnaam. "
";
$result2 = mysql_query($sql);
echo 'Gebruiker Toegevoegd';
$result3 = mysql_query("select userid from users where usern = $unaam"
;
$userid = mysql_fetch_row($result3);
$result4 = mysql_query("select groupid from groups"
;
$tot_row = mysql_num_rows($result4);
for ($i=0; $i < $tot_row; $i++)
{
$groupid = $_POST['groep'][$i];
$result5 = mysql_query("insert into usergroup (userid, groupid) values ( $userid, $groupid)"
;
}
}
mysql_close();
}
else
{
echo 'Paswoorden komen niet overeen.';
}
}
else
{
echo 'U moet alle velden invullen.';
}
?>
*****************end user_o.php*********************
And I shall post the php myadmin exports of the tables that are used.
CREATE TABLE `users` (
`userid` int(11) NOT NULL auto_increment,
`usern` varchar(100) NOT NULL default '',
`userp` varchar(100) NOT NULL default '',
`naam` varchar(100) NOT NULL default '',
`vnaam` varchar(100) NOT NULL default '',
PRIMARY KEY (`userid`)
) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2;
CREATE TABLE `groups` (
`groupid` int(11) NOT NULL auto_increment,
`naam` varchar(100) NOT NULL default '',
PRIMARY KEY (`groupid`)
) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=4 ;
INSERT INTO `groups` VALUES (1, 'Administratie');
INSERT INTO `groups` VALUES (2, 'Opvoeders');
INSERT INTO `groups` VALUES (3, 'Onderhoud');
CREATE TABLE `usergroup` (
`ugid` int(11) NOT NULL auto_increment,
`userid` int(11) NOT NULL default '0',
`groupid` int(11) NOT NULL default '0',
PRIMARY KEY (`ugid`)
) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=1 ;
The database is called rcomdb
When I execute this script I get this output
testtesttesttest
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\inetpub\ on line 18
Gebruiker Toegevoegd
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\inetpub\ on line 28
Notice: Undefined offset: 2 in c:\inetpub\ on line 33
Notice: Undefined offset: 3 in c:\inetpub\ on line 33
Also there is no user created in the database so it seems that even the insert into is failed but it gave not an error.
can anyone helping me??
I installed PHP 4.3.3.3 and MySQL 4.1 on IIS (Standard version on winXP pro I think it is 5)
Tank you so much.
I post my source code here
This one works.
********user_i.php*********************
<html>
<body>
<table>
<form method="post" action="user_o.php">
<tr>
<td>GEBRUIKERSNAAM:</td><td><input type="text" name="unaam"></td>
</tr>
<tr>
<td>NAAM:</td><td><input type="text" name="anaam"></td>
</tr>
<tr>
<td>VOORNAAM:</td><td><input type="text" name="vnaam"></td>
</tr>
<tr>
<td>PASWOORD:</td><td><input type="password" name="paswoord"></td>
</tr>
<tr>
<td>PASWOORD NOGMAALS:</td><td><input type="password" name="paswoordc"></td>
</tr>
<tr>
<td colspan=2>IS LID VAN</td>
</tr>
<?php
$con = mysql_connect("localhost", "root", ""

mysql_select_db("rcomdb"

$rec = mysql_query("select * from groups"

$i=1;
while (list($id, $gnaam) = mysql_fetch_row($rec))
{
echo "<tr><td>" . $gnaam . "</td><td><input type='checkbox' name='groep[]' value='" . $id . "'></td></tr>";
$i=$i + 1;
}
?>
<tr>
<td>
<input type="submit" name="Submit" value="Toevoegen">
</td>
</tr>
</form>
</table>
</body>
</html>
****************end user_i.php***********************
This one has the error's
***************user_o.php**********************
<?php
$unaam = $_POST['unaam'];
$paswoord = $_POST['paswoord'];
$paswoordc = $_POST['paswoordc'];
$anaam = $_POST['anaam'];
$vnaam = $_POST['vnaam'];
echo $unaam . $paswoord . $anaam . $vnaam;
if ($unaam <> '' && $paswoord <> '' && $anaam <> '' && $vnaam <> '')
{
if ($paswoord == $paswoordc)
{
$db = mysql_connect("localhost","root",""

mysql_select_db ("rcomdb"

$sql = "select usern from users where usern = ". $unaam;
$result1 = mysql_query($sql);
if (mysql_num_rows($result1)>0)
{
echo 'Gebruiker bestaat reeds';
}
else
{
$sql = "insert into users (usern, userp, naam, vnaam) values (" .$unaam. "," .$paswoord. "," .$anaam. "," .$vnaam. "

$result2 = mysql_query($sql);
echo 'Gebruiker Toegevoegd';
$result3 = mysql_query("select userid from users where usern = $unaam"

$userid = mysql_fetch_row($result3);
$result4 = mysql_query("select groupid from groups"

$tot_row = mysql_num_rows($result4);
for ($i=0; $i < $tot_row; $i++)
{
$groupid = $_POST['groep'][$i];
$result5 = mysql_query("insert into usergroup (userid, groupid) values ( $userid, $groupid)"

}
}
mysql_close();
}
else
{
echo 'Paswoorden komen niet overeen.';
}
}
else
{
echo 'U moet alle velden invullen.';
}
?>
*****************end user_o.php*********************
And I shall post the php myadmin exports of the tables that are used.
CREATE TABLE `users` (
`userid` int(11) NOT NULL auto_increment,
`usern` varchar(100) NOT NULL default '',
`userp` varchar(100) NOT NULL default '',
`naam` varchar(100) NOT NULL default '',
`vnaam` varchar(100) NOT NULL default '',
PRIMARY KEY (`userid`)
) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2;
CREATE TABLE `groups` (
`groupid` int(11) NOT NULL auto_increment,
`naam` varchar(100) NOT NULL default '',
PRIMARY KEY (`groupid`)
) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=4 ;
INSERT INTO `groups` VALUES (1, 'Administratie');
INSERT INTO `groups` VALUES (2, 'Opvoeders');
INSERT INTO `groups` VALUES (3, 'Onderhoud');
CREATE TABLE `usergroup` (
`ugid` int(11) NOT NULL auto_increment,
`userid` int(11) NOT NULL default '0',
`groupid` int(11) NOT NULL default '0',
PRIMARY KEY (`ugid`)
) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=1 ;
The database is called rcomdb
When I execute this script I get this output
testtesttesttest
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\inetpub\ on line 18
Gebruiker Toegevoegd
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\inetpub\ on line 28
Notice: Undefined offset: 2 in c:\inetpub\ on line 33
Notice: Undefined offset: 3 in c:\inetpub\ on line 33
Also there is no user created in the database so it seems that even the insert into is failed but it gave not an error.
can anyone helping me??
I installed PHP 4.3.3.3 and MySQL 4.1 on IIS (Standard version on winXP pro I think it is 5)
Tank you so much.