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!
can we see a live example of this happening? Because I'm not quite understanding "displays fine. " and "how can i bring the quotes out to?" happening at the same time...
<?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_CostPrice = stripslashes($_POSTї"P_CostPrice"]);
$P_Price = stripslashes($_POSTї"P_Price"]);
// grab foo and make sure it is in it's original state
if (get_magic_quotes_gpc())
{
$P_Desc = stripslashes($_POSTї"P_Desc"]);
}
else
{
$P_Desc = $_POSTї"P_Desc"];
}
// now make it ready to be inserted in our database
$P_Desc = mysql_real_escape_string($P_Desc, $db);
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 (!mysql_num_rows($result1))
{
$sql = "INSERT INTO planes (P_Stock, P_Name, P_Cat, P_Scale, P_Length, P_Span, P_CostPrice, P_Price, P_Desc) VALUES ('$P_Stock','$P_Name','$P_Cat','$P_Scale','$P_Length','$P_Span','$P_CostPrice','$P_Price','$P_Desc')";
$result = mysql_query($sql, $db) or die ("Execution failed: ".mysql_error());
move_uploaded_file($_FILESї'file']ї'tmp_name'], '/var/users/modelair/deskjetmodels.co.nz/htdocs/pics/'.$_FILESї'file']ї'name']);
echo 'File has been stored in your uploads directory.';
echo "<br /><br /> <strong>new aircraft added</strong> <br /><br />";
echo realpath('.');
}
else
{
echo "<br /><br /> <strong> Duplicate Stockcode</strong> <br /><br />";
}
}
else
{
echo "<br /><br /> <strong>Make sure stock code AND name are filled out</strong>";
}
}
?>