I have this code which ironically WORKS on another page i have but for some reason will not work with my new page even though LITERALLY its the exact same function and should work regardless but with my luck it wont so i need help, maybe i have a small error but i have compared and compared the code time and time again and theres literally no difference from what i can tell.
here is the code:
<?php
$con = mysqli_connect("localhost", "root", "", "numbers") or die(mysqli_error($con));
//submission code, inserting data into mysql database
$username = NULL;
$password = NULL;
$mySqlDate = date('Y-m-d');
$mySqlTime = date('g:i a');
if(isset($_GET['add']))
{
$username = $_GET['username'];
$password = $_GET['password'];
}
//filter out non numeric and special characters
$username = mysqli_real_escape_string($con, $_GET['username']);
$password = mysqli_real_escape_string($con, $_GET['password']);
$check = mysqli_query($con, "SELECT count(*) FROM admin WHERE username = '".$username."'") or die();
$row = mysqli_fetch_row($check);
if ($row[0] == 0)
{
$sql="INSERT INTO admin (username, password, date, time) VALUES ('".$username."','".$password."','".$mySqlDate."','".$mySqlTime."')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
$length = "Remember to use lower case letters and do not use spaces";
echo "<font size='5' color='blue'>".$length."</font> ";
}
else
{
$length = "Remember to use lower case letters and do not use spaces";
echo "<font size='5' color='blue'>".$length."</font> ";
}
?>
<html>
<form method="post" action="index.php">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<div style = "margin-bottom: 100px" >
<tr width="200">
<font size="6">
Add a New User with Administrative Privileges
</tr>
</font>
</div>
<tr>
<td width="100">Username:</td>
<td>
<input name="username" type="text" id="username">
</td>
</tr>
<tr>
<td style="width:100%;" width="200">Password:</td>
<td>
<input name="password" type="text" id="password">
</td>
</tr>
<tr>
<td>
<input name="add" type="submit" id="add" value="Submit">
</td>
</tr>
</table>
</form>
</html>
this is the adduser.php file
any and all help is greatly appreciated!