Jump to content

[SOLVED] Simple Form Help???


will35010

Recommended Posts

I have this form. It's not submitting to the database. I have error reporting on, but it doesn't give an error. Can you see what I'm missing? Thanks!

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LG Player Ban Management</title>
</head>
<body>
<table width="100%" border="10">
  <tr>
    <th scope="col">LG Ban Management System</th>
  </tr>
</table>
<table width="100%" border="10">
  <tr>
    <th scope="col"><a href="viewplayer.php">View Banned Players</a></th>
  </tr>
</table>
<table width="100%" height="298" border="10" align="center">
  <tr>
    <th height="294" valign="top" scope="col"><form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      <p>Player's Name:
        <input type="text" name="playername" id="playername" />
      </p>
      <p>IP Address:
        <input type="text" name="ip" id="ip" />
      </p>
      <p>Reason for Ban:
        <textarea name="reason" id="reason" cols="45" rows="5"></textarea>
      </p>
      <p>Admin that Banned:
        <input type="text" name="admin" id="admin" />
      </p>
      <p>
        <input type="submit" name="submit" id="submit" value="Submit" />
      </p>
      <p> </p>
      </form>
    </th>
  </tr>
</table>

<?php
error_reporting(E_ALL);
ini_set("display_errors", "on");


if (isset($_POST['playername'])) {
$player = $_POST['playername'];
$ip = $_POST['ip'];
$reason = $_POST['reason'];
$admin = $_POST['admin'];
$date = date('Y-m-d');

$dbhost = "localhost"; 
$dbuser = "root"; 
$dbpass = ""; 
$dbname = "lgbans";

$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die        
                     ('Error connecting to mysql');
                     
//Query to insert driver data
$query = "INSERT INTO bans (playername, ip, date, reason, admin) VALUES ('$player', '$ip', '$date', '$reason', '$admin')";

//send query to database
mysqli_query($conn, $query) or die('Error: ' . mysql_error());                     

}
?>

Link to comment
https://forums.phpfreaks.com/topic/165801-solved-simple-form-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.