<?php
include 'includes/db_inc.php';
db_connect('localhost','root','');
/*
mysql_query('"'.$query.'"') or die('<font color="red"><br>'.mysql_error().'</font>');
*/
if(!isset($_POST['todo']))
{
echo '<p>What would you like to do?</p>
<form name="todo" method="post" action="">
<p>
<input name="todo" type="radio" value="view">View Users
</p>
<p>
<input name="todo" type="radio" value="import">Import Users
</p>
<p>
<input name="todo" type="radio" value="delete">Delete Users
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>';
} elseif($_POST['todo'] == view) {
db_select('rsc');
$results = mysql_query("SELECT * FROM rsc ORDER BY username ASC ") or die('<font color="red"><br>'.mysql_error().'</font>');
echo '<table border="1">';
echo '<tr><td>Username</td><td>Password</td>
<td>Frist Name</td><td>Last Name</td><td>Email</td></tr>
<form action="printuser.php" method="post">';
while($rowarray = mysql_fetch_array($results) or die(mysql_error())) {
echo '<tr>';
echo '<td>';
echo $rowarray['username'];
echo '</td>';
echo '<td>';
echo $rowarray['password'];
echo '</td>';
echo '<td>';
echo $rowarray['first_name'];
echo '</td>';
echo '<td>';
echo $rowarray['last_name'];
echo '</td>';
echo '<td>';
echo $rowarray['email'];
echo '</td>';
echo '</tr>';
}
echo '</table>';
echo '<a href="index.php">Home</a>';
} elseif($_POST['todo'] == import) {
echo '<body>
<form name="UserInput" method="post" action="index.php?do=import">
<table width="300" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td colspan="2" align="right" valign="top" nowrap><div align="left">User name And Password Input:</div></td>
</tr>
<tr>
<td width="78" align="right" valign="top" nowrap><div align="right">User Name:</div></td>
<td width="528"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td width="78" align="right" valign="top" nowrap><div align="right">Password:</div></td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td align="right" valign="top" nowrap>First Name </td>
<td><input name="fname" type="text" id="fname"></td>
</tr>
<tr>
<td align="right" valign="top" nowrap>Last Name </td>
<td><input name="lname" type="text" id="lname"></td>
</tr>
<tr>
<td align="right" valign="top" nowrap>Email</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td width="78" align="right" valign="top" nowrap><div align="right">Which Site:</div></td>
<td>Edifi Sales (Working on both) </td>
</tr>
<tr>
<td align="right" valign="top" nowrap><input type="submit" name="Submit" value="Submit"></td>
<td><input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</body>';
} elseif($_POST['todo'] == delete) {
db_select('rsc');
$result = mysql_query('SELECT * FROM rsc') or die('<font color="red"><br>'.mysql_error().'</font>');
echo ' <form action="index.php?do=delete" method="POST"> ';
while ($row = mysql_fetch_assoc($result))
{
echo '<input type="radio" name="del[]" value="' . $row['username'] . '"> ' . $row['username'] . '<br>';
}
echo ' <br>
<input type="submit" name="submit" value="submit">
</form>
';
}
switch ($_GET['do']) {
case 'import':
db_select('rsc');
mysql_query("INSERT INTO rsc (username, password, first_name, last_name, email) VALUES ('$_POST[username]', '$_POST[password]', '$_POST[fname]', '$_POST[lname]', '$_POST[email]')");
}
switch ($_GET['do']) {
case 'delete':
if (isset($_POST['del']))
{
db_select('rsc');
$result = mysql_query("DELETE FROM rsc WHERE username = '".(implode(',',$_POST['del'])."'"));
}
}
?>
When i try to import a user it put in the user info and then also imports a row of blanks?
any one have any idea why this is?