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 3 years ago

391 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years 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;}
        
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum