Jump to content

Recommended Posts

<?php
if ($_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>

Link to comment
https://forums.phpfreaks.com/topic/278767-need-to-find-error-in-this-code/
Share on other sites

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 by Jessica
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.