[PHP] Am i missing something here?

Soldato
Joined
30 Jun 2003
Posts
2,807
Location
Berkshire
Just a simple submit form sending data to the MySQL database. The script connects but does not insert the data

form.php
Code:
<?php

	echo '<form action="admin/_serverstatus.php" method="post">';
	echo '<input name="server" type="text" value="Server" /> << Server IP ';
	echo '<input name="submit" type="submit" value="Add" />';
	echo '</form>';

?>

admin/_serverstatus.php

Code:
	<?php
	include_once '../db.php';
	// process the form
	
	// clean the username and password
	$server = mysql_real_escape_string($_POST['Server']);
	
	// check for valid details
	$sql = mysql_query("INSERT INTO `uptime` VALUES ('$server')");
	
	if ($sql)
	{
		// success
		echo 'Server has been added';
		
	}
	else
	{
		// failure
		echo 'nope';
		echo mysql_error();
	}	


?>
 
i update it as the row it enters into is called server

Code:
	<?php
	include_once '../db.php';
	// process the form
	
	// clean the username and password
	$server = mysql_real_escape_string($_POST['Server']);
	
	// check for valid details
	$sql = mysql_query("INSERT INTO `uptime` (`server`) VALUES ('$server')");
	
	if ($sql)
	{
		// success
		echo 'Server has been added';
		
	}
	else
	{
		// failure
		echo 'nope';
		echo mysql_error();
	}	


?>
 
changed letter to lowercase

$server = mysql_real_escape_string($_POST['Server']);

to

$server = mysql_real_escape_string($_POST['server']);
 
Back
Top Bottom