PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$db = mysql_pconnect('**', '**', '**') or die ("Could not connect to database");
# mysql_select_db('models') or die ("Could not select database!");
# this is processed when the form is submitted
# back on to this page (POST METHOD)
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
# escape data and set variables
mysql_select_db('models') or die ("Could not select database!");
$P_Stock = stripslashes($_POST["P_Stock"]);
$P_Name = stripslashes($_POST["P_Name"]);
$P_Cat = stripslashes($_POST["P_Cat"]);
$P_Scale = stripslashes($_POST["P_Scale"]);
$P_Length = stripslashes($_POST["P_Length"]);
$P_Span = stripslashes($_POST["P_Span"]);
$P_Price = stripslashes($_POST["P_Price"]);
$P_Desc = stripslashes($_POST["P_Desc"]);
if (!empty($P_Stock) && !empty($P_Name))
{
$sql1 = "select * from planes where P_Stock = '$P_Stock'";
$result1 = mysql_query($sql1,$db) or die("Execution failed: ".mysql_error());
if (!$sql1);
{
$sql = "INSERT INTO planes (P_Stock, P_Name, P_Cat, P_Scale, P_Length, P_Span, P_Price, P_Desc) VALUES ('$P_Stock','$P_Name','$P_Cat','$P_Scale','$P_Length','$P_Span','$P_Price','$P_Desc')";
$result = mysql_query($sql, $db) or die ("Execution failed.");
move_uploaded_file($_FILES['file']['tmp_name'], '/var/users/modelair/modelaircraft.co.nz/htdocs/Pics/'.$_FILES['file']['name']);
echo 'File has been stored in your uploads directory.';
echo "<br><b>new aircraft added</b><br><br>";
}
else
{
echo "<br><b>Duplicate Stockcode</b><br><br>";
}
}
else
{
echo "<br><b>Make sure stock code AND name are filled out</b><br><br>";
}
}
?>
you can get both POST and GET variables from the browser. If you want to see what the browser is using try [php_man]print_r[/php_man] and see what you have.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/users/modelair/modelaircraft.co.nz/htdocs/admin/insert.php on line 182