· 8 years ago · May 01, 2018, 05:08 AM
1
2<html>
3<body>
4
5<!--
6php version, make sure not vb stuff ....
7-->
8
9<form action="" method="post">
10Accountid: <input type="text" name="accountid" size="20"><br>
11Password: <input type="text" name="pw" size="20"><br>
12Confirm Password: <input type="text" name="cpw" size="20"><br>
13<input type="submit" value="Submit">
14</form>
15
16<!--
17The setting of the above form is consistent to the table that we will deal with
18So, make sure you have created the below table under your account.
19
20create table sampleuser
21(
22 userid varchar2(10) primary key,
23 passwd varchar2(10)
24);
25
26
27-->
28
29<?php
30
31
32$msg1="The password confirmation does not match the password!";
33$msg2="The accountid already exists in the account table!";
34$msg3="The new account has been created successfully!";
35$newline="<br>";
36
37$accountid=$_POST["accountid"];
38$pw=$_POST["pw"];
39$cpw=$_POST["cpw"];
40
41$conn = oci_connect('s15zhangs', '88888888', 'csci242');
42
43$sql = 'BEGIN sp_newuser(:accountid, :pw, :cpw, :flag); END;';
44
45$stmt = oci_parse($conn,$sql);
46
47// Bind the input parameter
48oci_bind_by_name($stmt,':accountid',$accountid,10);
49oci_bind_by_name($stmt,':pw',$pw,10);
50oci_bind_by_name($stmt,':cpw',$cpw,10);
51
52$whichanswer;
53// Bind the output parameter
54oci_bind_by_name($stmt,':flag',$whichanswer);
55
56oci_execute($stmt);
57
58// $message is now populated with the output value
59print "$whichanswer\n";
60
61switch($whichanswer)
62{
63 case 1:
64 $msg=$msg1;
65 break;
66
67
68 case 2:
69 $msg=$msg2;
70 break;
71
72 case 3:
73 $msg=$msg3;
74 break;
75
76}
77print $msg;
78//in fact, if you make the output to return message directly, then you can save the switch in php to make the php part even ligher.
79
80// should be automatically committed and closed ... clean up
81oci_free_statement($stid);
82oci_commit($conn);
83oci_close($conn);
84
85?>
86
87</body>
88</html>