Pushpender_rana Posted June 4, 2013 Share Posted June 4, 2013 <?phpif ($_POST['cmdSubmit'] != '') { $imgName = time(); if ($_FILES['txtImage']['name'] != '') { $sql = "INSERT INTO news SET head = '".htmlspecialchars($_POST['head'], ENT_QUOTES). "', news = '". htmlspecialchars($_POST['news'], ENT_QUOTES). "', validity = '".htmlspecialchars($_POST['validity'], ENT_QUOTES)."', terms = '".htmlspecialchars( $_POST['terms'], ENT_QUOTES).'"'; $res = mysql_query($sql); if ($res) { $id = mysql_insert_id(); $source = $_FILES['txtImage']['tmp_name']; //Upload file temp Path $dest = BASEPATH . "images/news/"; //Destinaltion folder $extntion = strstr($_FILES['txtImage']['name'], "."); //Extension $newname = "Image-" . $imgName . $extntion; //File Extensions $destination = $dest . $newname; //Destination Full Path if (move_uploaded_file($source, $destination)) { $sqlup = "update news set image = '" . $newname . "' where id = " . $id; mysql_query($sqlup); } else { die('Error in Uploading File'); } } } header("location:home.php?option=news");}?><table><tr><td><h2>Add Panel</h2></td></tr></table><form name="frmAdd" action="" method="post" enctype="multipart/form-data"> <table cellpadding="2" cellspacing="2" border="1" align="center" width="85%"> <tr> <td>Heading</td> <td><input type="text" name="head"></td> <tr> <tr> <td>Image</td> <td><input type="file" name="txtImage" value="" /></td> </tr> <tr> <td>News</td> <td><input type="text" name="news" value="" /></td> </tr> <tr> <tr> <td>Validty</td> <td><input type="text" name="validity" value="" /></td> </tr> <tr> <tr> <td>Terms</td> <td><textarea name="terms" cols="40" rows="5"></textarea></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="cmdSubmit" value="submit"></td> </tr> </table></form> Quote Link to comment Share on other sites More sharing options...
Pushpender_rana Posted June 4, 2013 Author Share Posted June 4, 2013 i m not able to insert data to the data base... Quote Link to comment Share on other sites More sharing options...
Jessica Posted June 4, 2013 Share Posted June 4, 2013 (edited) PHPFreaks.com Questions, Comments, & Suggestions This is NOT a help forum! Do not post topics asking for help that are not related to the website. http://www.phpfreaks.com/page/rules-and-terms-of-service Users will format posts as best as they can by using proper [/nobbc] or [nobbc] tags and following Proper Code Indentation guidelines. Users will post relevant code and information to their question(s). Read the link in my signature on Debugging your SQL. Research using prepared statements. Edited June 4, 2013 by Jessica 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.