-7
<?php
include"connect.php";

    $name =     $_REQUEST['name'];
    $address =  $_REQUEST['address'];
    $password =     $_REQUEST['password'];
    $email =    $_REQUEST['email'];
    $number =   $_REQUEST['number'];
    $hear =     $_REQUEST['hear'];
    $money =    $_REQUEST['money'];
    $artist =   $_REQUEST['artist'];
    $security = $_REQUEST['security'];
    $city =     $_REQUEST['city'];
    $pro =  $_REQUEST['pro'];
    $role =     $_REQUEST['role'];
    $accname =  $_REQUEST['accname'];
    $accpass =  $_REQUEST['accpass'];
    $accno =    $_REQUEST['accno'];
    $seaccname =    $_REQUEST['seaccname'];
    $seaccpass =    $_REQUEST['seaccpass'];
    $seaccno =  $_REQUEST['seaccno'];
    $contracts = $_REQUEST['contracts'];
    $statements =   $_REQUEST['statements'];

    $result = mysqli_query($con, "insert into signup set name='$name',email='$email',password='$password' ,address='$address',cell_phone_number='$number',heard_from='$hear',money_time='$money',fav_artist='$artist',fav_city='$city',security_question='$security',pro='$pro',pro_acc_name='$accname',pro_acc_password='$accpass',pro_acc_number='$accno',se_acc_name='$seaccname',se_acc_pass='$seaccpass',se_ac_number='$seaccno',rec_contract_copy='$contracts',rec_label_copy='$statements',role='$role'");

//$result= mysqli_query($con, "INSERT INTO signup (name, email,password, address,cell_phone_number, heard_from,money_time, fav_artist,fav_city,security_question, pro,pro_acc_name, pro_acc_password,pro_acc_number, se_acc_name,se_acc_pass, se_ac_number,rec_contract_copy, rec_label_copy,role) VALUES ('$name', '$email', '$password', '$address', '$number', '$hear', '$money', '$artist', '$security', '$city', '$pro', '$role', '$accname', '$accpass', '$accno', '$seaccname', '$seaccpass', '$seaccno', '$contracts', '$statements')");



    if($result==true)
    {
        //echo "<script>alert('user successfully added')</script>";
        echo "Success";

    }
else{

    echo "Failed" ;

}


?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • check for the real errors then. If you don't know how, please ask. The connnection is unknown and if all `$_REQUEST`'s have value or not. – Funk Forty Niner Oct 04 '17 at 18:13
  • what's the output of mysqli_error($con)? – LordNeo Oct 04 '17 at 18:15
  • 2
    Your code is vulnerable to [**SQL injection**](https://en.wikipedia.org/wiki/SQL_injection) attacks. You should use prepared statements with bound parameters, via either the [**mysqli**](https://secure.php.net/manual/en/mysqli.prepare.php) or [**PDO**](https://secure.php.net/manual/en/pdo.prepared-statements.php) drivers. [**This post**](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) has some good examples. – Alex Howansky Oct 04 '17 at 18:16
  • i have three forms on the same page but on different slides with the button to move from one page to another and in the last a finish button to submit the data and send to the database but its not working and displaying failed by echo in this code, and i am using ajax for that. – Yash Singhal Oct 05 '17 at 02:21

2 Answers2

0

It won't run because your query is wrong, you are using insert statement with update format.

$result= mysqli_query($con, "INSERT INTO signup (name, email,password, address,cell_phone_number, heard_from,money_time, fav_artist,fav_city,security_question, pro,pro_acc_name, pro_acc_password,pro_acc_number, se_acc_name,se_acc_pass, se_ac_number,rec_contract_copy, rec_label_copy,role) VALUES ('$name', '$email', '$password', '$address', '$number', '$hear', '$money', '$artist', '$security', '$city', '$pro', '$role', '$accname', '$accpass', '$accno', '$seaccname', '$seaccpass', '$seaccno', '$contracts', '$statements')");

and further info, Start using Prepared Statement PDO

0

It looks ok. Problem could be in connect.php or the names in $_REQUEST are not the same as in file where request is sent. Also check that names of atributes in database you are inserting into match those in query.

Ana
  • 11
  • 3