Jump to content

Recommended Posts

Hi,

I've got this form:

<form name="adddates" method="post" action="editbooking.php">
		<select name="day" size="1">
			<option value="" selected="selected">day</option>
			<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>
			<option value="6">6</option>
			<option value="7">7</option>
			<option value="8">8</option>
			<option value="9">9</option>
			<option value="10">10</option>
			<option value="11">11</option>
			<option value="12">12</option>
			<option value="13">13</option>
			<option value="14">14</option>
			<option value="15">15</option>
			<option value="16">16</option>
			<option value="17">17</option>
			<option value="18">18</option>
			<option value="19">19</option>
			<option value="20">20</option>
			<option value="21">21</option>
			<option value="22">22</option>
			<option value="23">23</option>
			<option value="24">24</option>
			<option value="25">25</option>
			<option value="26">26</option>
			<option value="27">27</option>
			<option value="28">28</option>
			<option value="29">29</option>
			<option value="30">30</option>
			<option value="31">31</option>
		</select>
		<select name="month" size="1">
			<option value="" selected="selected">month</option>
			<option value="1">Jan</option>
			<option value="2">Feb</option>
			<option value="3">Mar</option>
			<option value="4">Apr</option>
			<option value="5">May</option>
			<option value="6">Jun</option>
			<option value="7">Jul</option>
			<option value="8">Aug</option>
			<option value="9">Sep</option>
			<option value="10">Oct</option>
			<option value="11">Nov</option>
			<option value="12">Dec</option>
		</select>
		<select name="year" size="1">
			<option value="" selected="selected">year</option>
			<option value="<?php echo date(Y); ?>"><?php echo date(Y); ?></option>
			<option value="<?php echo date(Y)+1; ?>"><?php echo date(Y)+1; ?></option>
		</select>
		<input type="submit" name="submit" value="submit" />
	</form>

as you can see I'm processing it through editbooking.php.

editbooking.php contains the following:

$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];

mysql_query("INSERT INTO `booked` VALUES ('$day', '$month', '$year')");
echo "Your information has been successfully added to the database.";

mysql_close($conn);

note that the database connection stuff has not been included in this example, although it is in the actual file.

When I submit my form it show the echo statement, so I presume it's worked, but if I check my database, nothing has been entered.

Could it be because the databse values are int instead of varchar?

thanks

Link to comment
https://forums.phpfreaks.com/topic/46517-solved-error-insert-into-using-form/
Share on other sites

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.