好的,让我先说我还是 PHP 的菜鸟。基本上,我正在尝试设计一个用户注册和登录系统,从 Oracle SQL 数据库中查询用户数据,唯一对我有帮助的教程都是针对 MYSQL 的。我想知道是否有人有时间帮助我进行一些 PHP 编码以使其正常工作。
任何帮助都将不胜感激。
编辑:对不起,我忘了提,我正在尝试获取一个登录页面,该页面设置一个 cookie 以保持用户会话直到他们注销。我尝试了一些不同的变体,但没有一个能像以前那样工作。我需要它与下面的注册页面一起使用。
我目前的用户注册代码,我相当确定是非常业余的,是:
<?php
/* Set oracle user login and password info */
$dbuser = "xxxxxxx"; /* your login */
$dbpass = "xxxxxx"; /* your password */
$db = "xxxxx";
$connect = OCILogon($dbuser, $dbpass, $db);
$salt = "plants";
if (!$connect) {
echo "An error occurred connecting to the database";
exit;
}
// get the max ID in plants table and allocate $ID+1 for the new record
$max_id_stmt = "SELECT max(ID) FROM register_table";
// check the sql statement for errors and if errors report them
$stmt = OCIParse($connect, $max_id_stmt);
if(!$stmt) {
echo "An error occurred in parsing the sql string.\n";
exit;
}
OCIExecute($stmt);
$ID =0;
if(OCIFetch($stmt)) {
$ID= OCIResult($stmt,1); //return the data from column 1
}else {
echo "An error occurred in retrieving book id.\n";
exit;
}
$ID++;
// Extract form data
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];
$email=$_REQUEST['email'];
$phone=$_REQUEST['phone'];
$address=$_REQUEST['address'];
global $salt;
// Create the SQL statement to add the data. Note: field value should be single quoted
'' if VARCHAR2 type.
$sql = "INSERT INTO register_table VALUES ($ID, '$username', '$password', '$email',
'$address', '$phone')";
$password = md5($salt.$password);
// Add the data to the database as a new record
$stmt = OCIParse($connect, $sql);
if(!$stmt) {
echo "An error occurred in parsing the sql string.\n";
exit;
}
OCIExecute($stmt);
echo ("<p>Your registration has been successful!</p>
<p>User ID: $ID</P>
<p>Username: $username</p>
<p>Phone: $phone</p>
<p>Address: $address</p>
</p>")
?>
谢谢!