0

Hello everyone,

I've searched a lot of time today for a solution, but not succeed!

I want to insert value from the radio button and checkbox into mysql database.

Here is my code:
insert.php

<div id="form">
		<form  method="post" action="process.php">
			<h1>BESOIN </h1>
			<br><br>
			<label>Sujet:</label><input type="text" name="sujet" />&nbsp;&nbsp;
			<label>Date: </label><input type="text" name="bdate" class="datepicker" id="datepicker1">&nbsp;&nbsp;
			<label>Nature:</label>
				<input type="radio" name="nature" id="nature" value="exprime" >Exprime</input>
				<input type="radio" name="nature" id="nature" value="non"/>Non Exprime<br><br>
			<h4>Action:</h4>
			<br>
				<label>Date de l'action: </label>
					<input type="text" name="adate" class="datepicker" id="datepicker2">
				<label>Date de l'alerte: </label>
					<input type="text" name="aldate" class="datepicker" id="datepicker3"><br><br>	
				<label>Etat: </label>
					<select>
						<option name="etat" value="ready">Ready</option>
						<option name="etat" value="transacting">Transacting</option>
						<option name="etat" value="finished"/>Finished</option>
					</select><br><br>
				<label>Detail: </label><br>
					<textarea rows="5" cols="40" name="adetail"></textarea>
				<br><br>
			<h4>Qualification: </h4>
			<br>
				<label>Date:  </label>
					<input type="text" name="qdate" class="datepicker" id="datepicker4"><br><br>
				<label>Detail: </label><br>
					<textarea rows="5" cols="40" name="qdetail"></textarea>  
				<br><br>
			<h4>Proposition: </h4>
			<br>
				<label>Date: </label>
					<input type="text" name="pdate" class="datepicker" id="datepicker5" /><br><br>
				<label>Detail: </label><br>
					<textarea rows="5" cols="40" name="pdetail"></textarea>  
				<br><br>
			<label>Nom du decideur: </label>
				<input type="text"  name="decideur" />
			<br><br>
			<input type="submit" name="submit" value="submit"/>
		</form>
	</div>

process.php

<div id="wcontent">
			<?php 
			$conne = mysql_connect($server, $user, $password) or die(mysql_error());
			mysql_select_db($db);
			
			$query = "INSERT INTO besoin
					(sujet, bdate, nature, adate, aldate, etat, adetail, qdate, qdetail, pdate, pdetail, decideur)
					VALUES('$_POST[sujet]','$_POST[bdate]','$_POST[nature]','$_POST[adate]','$_POST[aldate]','$_POST[etat]','$_POST[adetail]','$_POST[qdate]','$_POST[qdetail]','$_POST[pdate]','$_POST[pdetail]','$_POST[decideur]')";
			$result = mysql_query($query) or die("Query failed: ".mysql_error());
			/*	if($result){
					echo "<p>Input data succeed!</p>";
				} else{
					echo "<p>Input data failed!</p>";
				}
			*/	
			echo "<p><a href=\"besoinlist.php\" >Back to Besoin list</a></p>"; 
		
			?>
		</div>

Error:

Notice: Undefined index: bdate in process.php on line 26

Notice: Undefined index: nature in process.php on line 26

Notice: Undefined index: etat in process.php on line 26

Notice: Undefined index: adetail in process.php on line 26

Notice: Undefined index: qdate in process.php on line 26

Notice: Undefined index: qdetail in process.php on line 26

Notice: Undefined index: pdate in process.php on line 26

Notice: Undefined index: pdetail in process.php on line 26

Notice: Undefined index: decideur in process.php on line 26

Input data succeed!

Does anyone can give me the guidance. Thanks very much!!!

Edited by garcon1986: complete the question, add some errors code

3
Contributors
8
Replies
19
Views
7 Years
Discussion Span
Last Post by garcon1986
0

I'm sorry, it's not checkbox, it's combobox. Now i fixed it. And i'm also working on "radio button".

Any idea is welcomed.

0

Hi,

Replace the insert query with this one and see if it works.

$query = "INSERT INTO besoin (sujet, bdate, nature, adate, aldate, etat, adetail, qdate, qdetail, pdate, pdetail, decideur) VALUES('".$_POST."','".$_POST."','".$_POST."','".$_POST."','".$_POST."','".$_POST."','".$_POST."','".$_POST."','".$_POST."','".$_POST."','".$_POST."','".$_POST."')";

1
$query = "INSERT INTO besoin (sujet, bdate, nature, adate, aldate, etat, adetail, qdate, qdetail, pdate, pdetail, decideur) VALUES('".$_POST['sujet']."','".$_POST['bdate']."','".$_POST['nature']."','".$_POST['adate']."','".$_POST['aldate']."','".$_POST['etat']."','".$_POST['adetail']."','".$_POST['qdate']."','".$_POST['qdetail']."','".$_POST['pdate']."','".$_POST['pdetail']."','".$_POST['decideur']."')";
0

Thanks for paranjyoti's help. But it seems like the former result.

I don't know whether i'm right or not.

And this is my table :

CREATE TABLE IF NOT EXISTS besoin(
	id int(11) NOT NULL AUTO_INCREMENT, 
	sujet varchar(255), 
	bdate date,
	nature tinyint,
	adate date,
	aldate date,
	etat varchar(255),
	adetail varchar(10000),
	qdate date,
	qdetail varchar(10000),
	pdate date,
	pdetail varchar(10000),
	dicideur varchar(255),
	PRIMARY KEY(id)
);

And when the property of column bdate is "tinyint". The value for bdate is always 0.

And now i change it to varchar(255).
And it works.
Thanks a lot for your help, paranjyoti!!!


And I wonder if the type must be varchar()??? Can anyone give me a clue???

0

If you want to store the date in the db use 'date' as a type;
for 'date and time both' =>'Datetime'
for 'texts and words' =>'Text'
for 'variable strings'=>'Varchar'
for storing integer numbers=>'int'
and so on

0

If you want to store the date in the db use 'date' as a type;
for 'date and time both' =>'Datetime'
for 'texts and words' =>'Text'
for 'variable strings'=>'Varchar'
for storing integer numbers=>'int'
and so on

yes, but why not use varchar for text that is less than 65535 bytes.
because i think text is limited in mysql database.

and my sql code about date, should be something like this? :

bdate datetime

I don't know if i'm right. Welcome for your correction.

0

yes, you can use varchar like varchar(600) but for storing date you are supposed to use date/datetime type only.

0

yes, you can use varchar like varchar(600) but for storing date you are supposed to use date/datetime type only.

Ok. Thanks a lot dude.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.