Jump to content

Recommended Posts

My problem is that there only get added the first 2 from the formular ! (type+status) rest are empty !


Site there send data !
[code]<? if($_GET[done] == "1") {
echo "<center><font color=green size=2 face=Arial>Øllet er Tilføjet !</font></center>";
}
?>
<head>
<meta http-equiv="Content-Language" content="da">
</head>

<div align="center">
&nbsp;<table border="0" width="550" cellspacing="0" cellpadding="0" style="border-top: 1px black solid; border-right: 1px black solid; border-left: 1px black solid; border-bottom: 1px black solid" id="table1">
<tr>
<td bgcolor="#CCCCCC" style="border-bottom: 1px black solid">&nbsp;&nbsp;<b><font face="Arial">Til Føj En Øl.....</font></b></td>
</tr>
<tr>
<td>
<form method="POST" action="beeradd.php">
<table border="0" width="100%" cellpadding="2" id="table2">
<tr>
<td><b><font face="Arial" size="2">Øl Type:</font></b></td>
<td><select size="1" name="type">
<option value="01">01 - Pilsner</option>
<option value="02">02 - Lager</option>
<option value="03">03 - English Strong Bitter (ESB)
</option>
<option value="04">04 - English Pale Ale</option>
<option value="05">05 - Indian Pale Ale (IPA)</option>
<option value="06">06 - Swartsbeer</option>
<option value="07">07 - Belgisk Strong Ale</option>
<option value="08">08 - Belgisk Pale Ale</option>
<option value="09">09 - British Brown Ale</option>
<option value="10">10 - Weizen</option>
<option value="11">11 - Dunkelweizen</option>
<option value="12">12 - Belgisk wit</option>
</select></td>
<td><b><font size="2" face="Arial">Status:</font></b></td>
<td><select size="1" name="status">
<option value="Planlagt">Planlagt</option>
<option value="Gæring">Gæring</option>
<option value="Lagering">Lagering</option>
<option value="Karbonering">Karbonering</option>
<option value="Drikke Klar">Drikke Klar</option>
<option value="Drukket">Drukket</option>
<option value="Helt Ud">Helt Ud</option>
</select></td>
</tr>
<tr>
<td height="7" colspan="4">
<fieldset style="padding: 2">
<legend align="center">
<p align="left"><b><font size="2" face="Arial">Smags
Barometer</font></b> </p>
</legend>
<div align="center">
<table border="0" width="300" cellspacing="0" cellpadding="0" id="table3">
<tr>
<td width="100"><font face="Arial" size="2">
Let</font></td>
<td width="100">
<p align="center">
<select size="1" name="smag1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></td>
<td align="right" width="100">
<font face="Arial" size="2">Kraftig</font></td>
</tr>
<tr>
<td width="100"><font face="Arial" size="2">
Mild</font></td>
<td width="100">
<p align="center">
<select size="1" name="smag2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></td>
<td align="right" width="100">
<font face="Arial" size="2">Bitter</font></td>
</tr>
<tr>
<td width="100"><font face="Arial" size="2">
Tør</font></td>
<td width="100">
<p align="center">
<select size="1" name="smag3">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></td>
<td align="right" width="100">
<font face="Arial" size="2">Sød</font></td>
</tr>
</table>
</div>
</fieldset></td>
</tr>
<tr>
<td height="6">
<b><font size="2" face="Arial">Bryg Dato:</font></b></td>
<td height="6">
<input type="text" name="dato" size="18"> dd-mm-åååå</td>
<td height="6">
</td>
<td height="6">
</td>
</tr>
<tr>
<td height="12" colspan="4">
<p align="center">
<textarea rows="7" name="komentar" cols="62"></textarea></td>
</tr>
</table>
<p align="center"><input type="submit" value="Send" name="B1"><input type="reset" value="Nulstil" name="B2"></p>
</form>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</div>[/code]

Page there riceive data !
[code]<?
include("../_doh/db.php.inc");
?>
<?
mysql_query("INSERT INTO beer (`beer_style`, `beer_status`, `beer_taste1`, `beer_taste2`, `beer_taste3`, `beer_brygdag`, `beer_coment`) values ('$_POST[type]', '$_POST[status]', '$POST[samg1]', '$POST[smag2]', '$POST[smag3]', '$POST[dato]', '$POST[komentar]')") or die(mysql_error());

header("Location: addbeer.php?done=1");
?>[/code]

Database table:
[code]CREATE TABLE `beer` (
  `beer_id` tinyint(10) NOT NULL auto_increment,
  `beer_style` varchar(200) NOT NULL default '',
  `beer_status` varchar(20) NOT NULL default '',
  `beer_taste1` tinyint(1) default '0',
  `beer_taste2` tinyint(1) NOT NULL default '0',
  `beer_taste3` tinyint(1) NOT NULL default '0',
  `beer_coment` text NOT NULL,
  `beer_brygdag` varchar(20) NOT NULL default '',
  PRIMARY KEY  (`beer_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;[/code]
Link to comment
https://forums.phpfreaks.com/topic/17404-problem-with-post-form-to-database/
Share on other sites

first i suggest you start using "proper" coding (saved me always from strange bugs, errors, etc...)

for your page that sends data
[code]
<?php
if ($_GET['done'] == "1") {
...
}
?>
[/code]

for your page that receives it!
[code]
<?php
// For readability have i added some newlines here
$Sql = sprintf(
"INSERT INTO `beer` (`beer_style`, `beer_status`, `beer_taste1`, `beer_taste2`, `beer_taste3`, `beer_brygdag`, `beer_coment`) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
$_POST['type'], $_POST['status'], $POST['samg1'], $POST['smag2'], $POST['smag3'], $POST['dato'], $POST['komentar']
);

if (mysql_query($Sql)) {
   // We don't wanna have error's like "headers already sent..." therefor this does the job as well!
   echo "<script>window.location.href='addbeer.php?done=1';</script>";
} else {
  echo mysql_error();// TODO: i know that the db_resource is optional, however i should consider providing this anyhow!
}
?>
[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.