aavik Posted August 20, 2014 Share Posted August 20, 2014 mysql.php<?php$con = mysql_connect("localhost","root","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("ckeditor",$con);?>---------------------------------------------------------add.php<?phpinclude("mysql.php");if(isset($_POST["button2"])){$sql="INSERT INTO cktext (section)VALUES('$_POST[select2]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }?>-----------------------------------------------------------------home.php<form id="form1" name="form1" method="post" action="add.php"><tr> <td>Section:</td> <td><select name="select2" id="select2"> <option selected="selected" value="MALE">Male</option> <option selected="" value="FEMAIL">FEMAIL</option> </select></td> </tr><input type="submit" name="button2" id="button2" value="Upload" /> </form>In DATABASE :- cktext table attribute "section" is varchar type.BUT IT RETURN ME BLANK OUTPUT. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 20, 2014 Share Posted August 20, 2014 Are you saying that "add.php" gives blank output? Is the record being inserted? What output are you expecting, other than an error message if the insert query fails? Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted August 21, 2014 Share Posted August 21, 2014 BUT IT RETURN ME BLANK OUTPUT. In add.php you are only running a query to insert a record into your ckeditor table. There is no other code in add.php to "output" anything. So that would be expected output if the script ran successfully. You need to be aware that using raw $_POST data (or any data from a user) in a query is extremely dangerous. You should sanitize any user input before using it in a query to protect yourself from SQL injection. I would strongly advise you to not use the mysql_* functions as these are now deprecated meaning they are no longer supported and could soon be removed from future versions of php. Instead use either MySQLi or PDO. Using prepared queries when using user input in a query. Quote Link to comment Share on other sites More sharing options...
aavik Posted August 22, 2014 Author Share Posted August 22, 2014 THIS IS MY FULL CODE .. EVERY VALUE TYPE IN THE FORM GET STROE BUT. <select name="select" id="select"> <option selected="selected" value="MALE">Male</option> <option selected="" value="FEMAIL">FEMAIL</option> </select> MALE or FEMAIL DOESN'T GET STORED in DATABASE. In DATABASE :- cktext table attribute "section" is varchar type. <form id="form1" name="form1" method="post" action="add.php"><table width="958" height="372"> <tr> <td width="69">Name:</td> <td width="608"><input name="textfield" type="text" id="textfield" size="40" /></td> </tr><tr> <td width="69">Email:</td> <td width="608"><input name="te" type="text" id="te" size="40" /></td> </tr> <tr> <td>Section:</td> <td><select name="select" id="select"> <option selected="selected" value="MALE">Male</option> <option selected="" value="FEMAIL">FEMAIL</option> </select></td> </tr> <tr> <td>Subject:</td> <td><select name="select2" id="select2"><option selected="selected" value="MA">Ma</option> <option selected="" value="FE">FE</option> </select></td> </tr> <tr> <td height="53">Description</td> <td><textarea name="textarea" id="textarea" cols="45" rows="3"></textarea></td> </tr> <tr> <td>Upload</td> <td> <label for="fileField"></label> <input name="fileField" type="file" id="fileField" size="40" /> </td> </tr> <tr> <td> </td> <td> <input type="submit" name="button2" id="button2" value="Upload" /> </td> </tr></table></form> Quote Link to comment Share on other sites More sharing options...
CroNiX Posted August 22, 2014 Share Posted August 22, 2014 ('$_POST[select2]')"; Look at your associative array there, you don't have quotes around 'select2' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.