Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
How can I insert the data to mySQL by PHP from JS prompt?

I'm new in PHP. When I try to use the js prompt and input the listname, that will no system error, but $result->execute() is always return false value.

I checked mySql is never stored the data, so I don't know what I miss.

<?php
    session_start();
    $_Code_ = $_GET['_Code_'];
    $Name = $_GET['Name'];
    $Open = $_GET['Open'];
    $Close = $_GET['Close'];
    $UpDown = $_GET['UpDown'];
    $mName = $_SESSION['mName'];

    function prompt($prompt_msg){
        echo("<script type='text/javascript'> var answer = prompt('".$prompt_msg."'); </script>");

        $answer = "<script type='text/javascript'> document.write(answer); </script>";
        return($answer);
    }

    $prompt_msg = "Input the listname:";
    $listname = prompt($prompt_msg);
    $_SESSION['ListName'] = $listname;

    include_once 'connect.php';

  

    $result = $mysqli->prepare("INSERT INTO list(mName, _Code_, ListName) VALUES (?, ?, ?)");
    $result->bind_param('sss', $mName, $_Code_, $test); 

    if($result->execute()){
        echo "<SCRIPT LANGUAGE='javascript'> 
                window.alert ('Success')
                window.location ='add.php'   
                </SCRIPT>";
    }
    else{
        echo "<SCRIPT LANGUAGE='javascript'> 
                window.alert ('Fail')   
                </SCRIPT>";
        echo($mName);
    }
    $result->close();
    
?>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!