Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

this code works fine when a new table is to be added but fails when the same table is to be updated

Course Queries Syllabus Queries

Max. 2000 characters
Replies

usr_profile.png

User

( 4 months ago )

 

when i try adding a new row of the 'syllabus' table it works fine but when i try to update that same table, the table is not updated. Instead it is redirected to a blank page.I've used this same idea in adding and updating various other tables.Adding is fine but in case of updating its the same story.

<?php
require('filehandler.php');//file handler
require('adminDB/sql_connect.php');
//password clean
function clean($string) {
    $string = str_replace(" ", "", $string);//Deletes the spaces.
    $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);//Removes special chars.
    return preg_replace('/-+/', '', $string);//Replaces multiple hyphens with single one.
                        }
function sqli($string){
    $string = str_replace(";","",$string);
    $string = str_replace("OR","",$string);
    $string = str_replace("SELECT","",$string);
    $string = str_replace("FROM","",$string);
    $string = str_replace("DELETE","",$string);
    $string = str_replace("TRUNCATE","",$string);
    $string = str_replace("OR 1","",$string);
    $string = str_replace("UPDATE","",$string);
    return $string;

                    }

    $_POST = sqli($_POST);


    if(($_POST['add']=="SUBMIT")||($_POST['addpic']=="UPLOAD")){

    switch($_POST['data']){
        case 'syllabus':
        if($_SESSION['auth']=="special"){
        if(($_POST['syllabusReg']!="")&&($_FILES['syllabusLink']['name']!="")){
        //call to file handler for DOC
        $link=fileHandler($_FILES['syllabusLink'],"doc");
        if($link!="1"){
        $sql="INSERT INTO cse.syllabus (syllabus_reg,syllabus_link) 
        VALUES ('".$_POST['syllabusReg']."','".$link."');";}}}
        else{header('Location:../home.php');exit;}
        

what's your interest