Jump to content

Oracle insert using php question


TheNix

Recommended Posts

$query = "INSERT into 'Users'('lastname','firstname','email','user_type','username',
'password') VALUES('".$_POST['lname']."','".$_POST['fname']."','".$_POST['email']."',
'sell','".$_POST['username']."',md5('".$_POST['password']."'))";

 

I think I'm doing the quotes or double quotes around the POSTs wrong but I'm not sure. I'm not getting an error but nothing is being recorded to the database. Please help.

 

Link to comment
https://forums.phpfreaks.com/topic/156138-oracle-insert-using-php-question/
Share on other sites

Try...

 

$query = "
    INSERT into Users
    (lastname, firstname, email, user_type, username, password)
    VALUES('".$_POST['lname']."', '".$_POST['fname']."', '".$_POST['email']."', 'sell', '".$_POST['username']."', md5('".$_POST['password']."'))
";

That didn't help, let me put the rest of the code in to see if the problem is there. First I make a connection to the database and only if the connection works does the rest of the code work.

 

 
$query = "INSERT into 'Users'('lastname','firstname','email','user_type','username','password') VALUES('".$_POST['lname']."','".$_POST['fname']."','".$_POST['email']."', sell','".$_POST['username']."',md5('".$_POST['password']."'))";
$parsed = oci_parse($dbconn, $query); //prepares query for execution
oci_execute($parsed); //execute the query
header("location:login.php");
oci_close($dbconn);

INSERT into 'Users'

You're using Oracle.... is your table name really case sensitive? Only use quotes around the table name in Oracle if the table name is actually case-sensitive or contains non-alphameric characters (normally they aren't) and you need to get the exact case/characters

 

Note: the same applies to column names

And I don't believe MD5 is a valid Oracle function, it's part of the dbms_obfuscation_toolkit.

 

You'd need to define something like:

CREATE OR REPLACE FUNCTION md5(v_input_string IN VARCHAR2)
    RETURN VARCHAR2
IS
    v_checksum  VARCHAR2(32);
BEGIN
    v_checksum := dbms_obfuscation_toolkit.md5(input_string => v_input_string);
    RETURN v_checksum;
END;

... Or just use PHP's md5 function??

 

$query = "
    INSERT into Users
    (lastname, firstname, email, user_type, username, password)
    VALUES('".$_POST['lname']."', '".$_POST['fname']."', '".$_POST['email']."', 'sell', '".$_POST['username']."', '".md5($_POST['password'])."')
";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.