Кажется, что-то здесь не хватает. Каждый отдельный стол, который я нахожу в Google или StackOverflow, на основе того, что я вижу, показывает, что мой код верен. ОДНАКО, каждый раз, когда я нажимаю «Отправить», он просто очищает страницу и возвращает меня к вершине. Я попытался свести его к основным полям (без функций), но это ничего не изменило.Проблемы с моей формой
Вот моя форма:
<form acction="/php/newcarcode.php" method="post">
<table style="width:575px">
<tr>
<th>Currently Own</th>
<td><input type="checkbox" name="own"></td>
<td></td>
</tr>
<tr>
<th style="width:175px">Year</th>
<td style="width:375px"><input type="text" name="year" style="width:340px"></td>
<td style="width:25px"></td>
</tr>
<tr>
<th>Make</th>
<td><select name="dropdown" style="width:344px"><?php make() ?></select></td>
<td></td>
</tr>
<tr>
<th>Model</th>
<td><select name="dropdown" style="width:344px"><?php model() ?></select></td>
<td></td>
</tr>
<tr>
<th>Trim</th>
<td><input type="text" name="trim" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Purchased</th>
<td><input type="date" name="purchased" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Engine</th>
<td><select name="engine" style="width:344px"><?php engine() ?></select></td>
<td><a href="newengine.php"><img src="/images/addnew.png" width="33px" height="25px"></a></td>
</tr>
<tr>
<th>Drivetrain</th>
<td><select name="drivetrain" style="width:344px"><?php drivetrain() ?></select></td>
<td></td>
</tr>
<tr>
<th>Transmission</th>
<td><select name="trans" style="width:344px"><?php trans() ?></select></td>
<td><a href="newengine.php"><img src="/images/addnew.png" width="33px" height="25px"></a></td>
</tr>
<tr>
<th>Driver</th>
<td><select name="driver" style="width:344px"><?php driver() ?></select></td>
<td><a href="newengine.php"><img src="/images/addnew.png" width="33px" height="25px"></a></td>
</tr>
<tr>
<th>Type</th>
<td><select name="dropdown" style="width:344px"><?php type() ?></select></td>
<td></td>
</tr>
<tr>
<th>Doors</th>
<td><input type="number" name="doors" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Color</th>
<td><input type="text" name="color" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Cost</th>
<td><input type="number" name="cost" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Sale Price</th>
<td><input type="number" name="sale" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Profit</th>
<td><input type="number" name="profit" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Profile Pic</th>
<td><input type="text" name="profile" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Photo Album</th>
<td><input type="text" name="album" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th>Thumbnail Pic</th>
<td><input type="text" name="thumbnail" style="width:340px"></td>
<td></td>
</tr>
<tr>
<th style="height: 75px">Notes</th>
<td><textarea type="text" name="notes" style="width:340px" rows="4"></textarea></td>
<td></td>
</tr>
<tr>
<th style="height: 75px">Mods</th>
<td><textarea type="message" name="mods" style="width:340px" rows="4"></textarea></td>
<td></td>
</tr>
</table>
<br>
<input type="submit" value="Submit">
</form>
А потом вот страница PHP, что он звонит:
<?php
$con = mysql_connect("server", "mycaradmin", "SuperSecretPassword") or die(mysql_error());
mysql_select_db("mycars") or die(mysql_error());
$year = $_POST[year];
$make = $_POST[make];
$model = $_POST[model];
$trim = $_POST[trim];
$engine = $_POST[engine];
$trans = $_POST[trans];
$doors = $_POST[doors];
$type = $_POST[type];
$color = $_POST[color];
$drivetrain = $_POST[drivetrain];
$driver = $_POST[driver];
$own = $_POST[own];
$purchase = $_POST[purchase];
$sale = $_POST[sale];
$profit = $_POST[profit];
$profile = $_POST[profile];
$notes = $_POST[notes];
$mods = $_POST[mods];
$album = $_POST[album];
$sql = " INSERT INTO mycars.vehicles (
VYear,
VMakeID,
VModelID,
VTrim,
VEngineID,
VTransID,
VNumDoors,
VTypeID,
VColor,
VDrivetrainID,
PeopleID,
VCurrentlyOwn,
VPurchasePrice,
VSalePrice,
VProfit,
VAttachments,
VNotes,
VModifications,
VAlbum,
VDateOfPurchase
)
VALUES (
'$year',
'$make',
'$model;',
'$trim',
'$engine',
'$trans',
'$doors',
'$type',
'$color',
'$drivetrain',
'$driver',
'$own',
'$purchase',
'$sale',
'$profit',
'$profile',
'$notes',
'$mods',
'$album',
)"
;
if (!mysql_query($con,$sql))
{
die('Error: ' . mysql_error($con));
}
echo "1 record added";
mysql_close($con);
>
ли, кажется, не имеет значения, что я могу изменить, я? получить те же результаты. Я недоумеваю.
"
form acction ... – OllyBarca
Кроме того, вы должны действительно использовать MySQLi, старый MySQL API устарел с PHP 5.5.0 и будет удален в будущее. – OllyBarca