oxygenproject
03-05-2010, 03:52 AM
G'day guys,
I have created a form inside the admin section of my website that inserts data into mysql.. and works a charm (its an account creation form). The only problem is that once I press submit it logs me out and returns to the home page of my web app.
So for example the url for the section i am in is: www.website.com/index.php?m=admin&view=create
when I press submit it takes me back to: index.php.
The code for the form is as follows, if that helps:
<?php
if($_POST["username"]) {
$connection = db_connect();
extract($_POST);
mysql_query("INSERT INTO `".$type."`".
"(`username`, `first_name`, `last_name`, `password`,".
"`email`, subjects".
") VALUES(".
"'$username', '$first_name','$last_name', '$password',".
"'$email', '$subjects')") or die(mysql_error());
}
?>
<form id="form1" name="form1" method="post" action="#">
<table width="465" border="0" align="center">
<tr>
<td colspan="2"><p><strong>Administration Creation Tool</strong></p>
<p><em>This allows you to add more users to your website.</em></p>
<p> </p></td>
</tr>
<tr>
<td width="165"><label>Username:</label></td>
<td width="290"><input name="username" type="text" id="username" size="35" /></td>
</tr>
<tr>
<td>First Name:</td>
<td><input name="first_name" type="text" id="first_name" size="35" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input name="last_name" type="text" id="last_name" size="35" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" type="password" id="password" size="35" /></td>
</tr>
<tr>
<td><label>Email Address:</label></td>
<td><input name="email" type="text" id="email" size="35" /></td>
</tr>
<tr>
<td>Account Type:</td>
<td><select name="type" id="type">
<option value="admins" selected="selected">Web Administrator</option>
<option value="teachers">Teacher</option>
<option value="students">Student</option>
<option value="parents">parents</option>
</select></td>
</tr>
<tr>
<td>Subjects (<strong><em>teachers Only</em></strong>)</td>
<td><label>
<textarea name="subjects" cols="35" rows="5" id="subjects">ie. SUB1A,SUB1B</textarea>
</label></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="submit" id="submit" value="Submit" />
</div></td>
</tr>
</table>
</form>
Please note: I have also tried putting in different things into ACTION in the form header (ie. #, the page itself, etc)
Anyhelp would be greatly appreciated!
I have created a form inside the admin section of my website that inserts data into mysql.. and works a charm (its an account creation form). The only problem is that once I press submit it logs me out and returns to the home page of my web app.
So for example the url for the section i am in is: www.website.com/index.php?m=admin&view=create
when I press submit it takes me back to: index.php.
The code for the form is as follows, if that helps:
<?php
if($_POST["username"]) {
$connection = db_connect();
extract($_POST);
mysql_query("INSERT INTO `".$type."`".
"(`username`, `first_name`, `last_name`, `password`,".
"`email`, subjects".
") VALUES(".
"'$username', '$first_name','$last_name', '$password',".
"'$email', '$subjects')") or die(mysql_error());
}
?>
<form id="form1" name="form1" method="post" action="#">
<table width="465" border="0" align="center">
<tr>
<td colspan="2"><p><strong>Administration Creation Tool</strong></p>
<p><em>This allows you to add more users to your website.</em></p>
<p> </p></td>
</tr>
<tr>
<td width="165"><label>Username:</label></td>
<td width="290"><input name="username" type="text" id="username" size="35" /></td>
</tr>
<tr>
<td>First Name:</td>
<td><input name="first_name" type="text" id="first_name" size="35" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input name="last_name" type="text" id="last_name" size="35" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" type="password" id="password" size="35" /></td>
</tr>
<tr>
<td><label>Email Address:</label></td>
<td><input name="email" type="text" id="email" size="35" /></td>
</tr>
<tr>
<td>Account Type:</td>
<td><select name="type" id="type">
<option value="admins" selected="selected">Web Administrator</option>
<option value="teachers">Teacher</option>
<option value="students">Student</option>
<option value="parents">parents</option>
</select></td>
</tr>
<tr>
<td>Subjects (<strong><em>teachers Only</em></strong>)</td>
<td><label>
<textarea name="subjects" cols="35" rows="5" id="subjects">ie. SUB1A,SUB1B</textarea>
</label></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="submit" id="submit" value="Submit" />
</div></td>
</tr>
</table>
</form>
Please note: I have also tried putting in different things into ACTION in the form header (ie. #, the page itself, etc)
Anyhelp would be greatly appreciated!