0

I have a HTML form that I want to add a record to an Oracle database when somebody hits submit. The table is hooking up somewhat, the problem is that when somebody submits their information they come up as NULL values in the database table.

HTML:

<form name="myForm" action="/Add_File.php" onsubmit="return validateForm()" method="post"><!--Form-->
<fieldset>
    <label class ="label1" for "name">First Name: </label>
    <input type="text" name="fname"><br />
    <label class ="label1" for "name">Surname: </label><input type="text" name="sname"><br/>
    <label for="email">E-mail Address: </label><input type="text" name="email"><br />
    <label  for "address">Address: </label> <input type="text" name="address"><br />
    <label class="label" for "Password">Select a Password: </label> <input type="password" name="pass"><br />
    <label class="label" for "Password">Retype-Password:</label> <input type="password" name="pass2"><br />
</fieldset>
<fieldset><input class="button" type="submit" onclick="message()" value="Submit"/>
    <input class="button" type="reset" value="reset form" onclick="myFunction()"/>
</fieldset>
</form>

PHP code:

$dbuser = "scott";
$dbpassword = "tiger";
$db = "orabis";
$conn = oci_connect($dbuser,$dbpassword,$db);

if (!$conn){
    echo "Connection error";
    exit;
}

$fname=$_POST['First_Name'];
$sname=$_POST['Surname'];
$email=$_POST['Email_Address'];
$address=$_POST['Address'];
$selpass=$_POST['Select_A_Password'];
$confirm=$_POST['Retype_Password'];

$sql = "INSERT INTO Become_A_Member_110385461(First_Name,Surname,Email_Address,Address,Select_A_Password,Retype_Password) 
VALUES ('".$fname."','".$sname."', '".$email."', '".$address."','".$selpass."', '".$confirm."')";

$stmt = oci_parse($conn, $sql);
if (!$stmt) {
    echo "Error in preparing the statement";
    exit;
}

oci_execute($stmt, OCI_DEFAULT);
print "Record Inserted";
oci_commit($conn);
oci_close($conn);
5
  • use oci_bind_by_name Commented Mar 24, 2014 at 16:17
  • Thanks Alexander, Im only a beginner tho, would u mind explaining what u mean? Commented Mar 24, 2014 at 16:19
  • I provided you with link in my comment. Meanwhile, your current issue should be solved by answer below Commented Mar 24, 2014 at 16:20
  • If you want to understand why you need to use oci_bind_by_name read about sql injections Commented Mar 24, 2014 at 16:21
  • Fantastic stuff lads, really appreciate it! Commented Mar 24, 2014 at 16:25

1 Answer 1

1

change like this

$fname=$_POST['fname'];
$sname=$_POST['sname'];
$email=$_POST['email'];
$address=$_POST['address'];
$selpass=$_POST['pass'];
$confirm=$_POST['pass2'];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.