Okay, I’m trying to send these sessions from my forms to a database. I need to use object approach when sending to database. I thought I had everything I needed but i’m missing something — Database name is conference table is registration
I would like to have a button do the job when it is pressed to call the sending of info to database – not if that is possible if someone could help, much appreciated!
CODE:
[code=php]<?php
session_start();
$_SESSION[‘apache’] = $_POST[‘apache’];
$_SESSION[‘docRea’] = $_POST[‘docRea’];
$_SESSION[‘geek’] = $_POST[‘geek’];
$_SESSION[‘javascript’] = $_POST[‘javascript’];
$_SESSION[‘mysql’] = $_POST[‘mysql’];
$_SESSION[‘php’] = $_POST[‘php’];
$_SESSION[‘web’] = $_POST[‘web’];
?>
<html>
<head>
<title> Registeration Page for Conference</title>
<body>
<form action = “m5donovanConfirmation.php” method = “post”>
<center>
<font color=”#C11B17″><h1>You have input the following data, if you need to make any changes, please do so now before submitting! Thanks</h1></font>
<br />
<h3><font color=”#FF0000″>Personal Information</font></h3>
E-mail:<input type=”text” name=”email” value=”<?php print $_SESSION[’email’];?>”><br />
First Name:<input type=”text” name=”firstName” value=”<?php print $_SESSION[‘firstName’];?>”> <br />
Last Name<input type=”text” name=”email” value=”<?php print $_SESSION[‘lastName’];?>”> <br />
Address:<input type=”text” name=”email” value=”<?php print $_SESSION[‘address’];?>”> <br />
City:<input type=”text” name=”email” value=”<?php print $_SESSION[‘city’];?>”> <br />
State:<input type=”text” name=”email” value=”<?php print $_SESSION[‘state’];?>”> <br />
Zip:<input type=”text” name=”email” value=”<?php print $_SESSION[‘zip’];?>”> <br />
Phone:<input type=”text” name=”email” value=”<?php print $_SESSION[‘phone’];?>”> <br />
<h3><font color = “#254117 “>Company Information</font></h3>
CO_Address:<input type=”text” name=”email” value=”<?php print $_SESSION[‘co_address’];?>”> <br />
CO_City:<input type=”text” name=”email” value=”<?php print $_SESSION[‘co_city’];?>”> <br />
CO_State:<input type=”text” name=”email” value=”<?php print $_SESSION[‘co_state’];?>”> <br />
CO_Zip:<input type=”text” name=”email” value=”<?php print $_SESSION[‘co_zip’];?>”> <br />
<h3><font color=”#AF7817″>Seminars you will be attending</font></h3>
Apache_Seminar:<input type=”text” name=”email” value=”<?php print $_SESSION[‘apache’];?>”> <br />
DocREa Fanclub:<input type=”text” name=”email” value=”<?php print $_SESSION[‘docrea’];?>”> <br />
Geek Seminar:<input type=”text” name=”email” value=”<?php print $_SESSION[‘geek’];?>”> <br />
Javascript Seminar:<input type=”text” name=”email” value=”<?php print $_SESSION[‘javascript’];?>”> <br />
Mysql Seminar:<input type=”text” name=”email” value=”<?php print $_SESSION[‘mysql’];?>”> <br />
PHP Seminar:<input type=”text” name=”email” value=”<?php print $_SESSION[‘php’];?>”> <br />
</form>
<?php
$DBConnect = @new mysqli(“localhost”, “root”, “”); // attempting to log on
if (mysqli_connect_errno())
die (“<p>Unable to connect to the database server.)</p>”
. “<p>Error code ” . mysqli_connect_errno ()
. “: ” . mysqli_connect_errnor()) . “</p>”;
$DBName = “conference”;
@$DBConnect ->select_db($DBName)
or die(“<p>Unable to select the database.</p>”
. “<p>Error code ” . mysqli_errno($DBConnect)
. “: ” . mysqli_error($DBConnect)) . “</p>”;
$TableName = “registeration”;
// gathers data to send to correct database and table
$email = $_SESSION[’email’];
$password = $_SESSION[‘password’];
$date = $_SESSION[‘date’];
$firstName = $_SESSION[‘firstName’];
$lastName = $_SESSION[‘lastName’];
$address = $_SESSION[‘address’];
$city = $_SESSION[‘city’];
$state = $_SESSION[‘state’];
$zip = $_SESSION[‘zip’];
$phone = $_SESSION[‘phone’];
$company = $_SESSION[‘company’];
$co_address = $_SESSION[‘co_address’];
$co_city = $_SESSION[‘co_city’];
$co_state = $_SESSION[‘co_state’];
$co_zip = $_SESSION[‘co_zip’];
$co_phone = $_SESSION[‘co_phone’];
$apache_seminar = $_SESSION[‘apache’];
$docrea_fanclub = $_SESSION[‘docRea’];
$geek_seminar = $_SESSION[‘geek’];
$javascript_seminar = $_SESSION[‘javascript’];
$php_seminar = $_SESSION[‘php’];
$web_services_seminar = $_SESSION[‘web’];
$SQLstring = “INSTERT INTO $TableName VALUES(‘$email’, ‘$password’, ‘$date’, ‘$firstName’, ‘$lastName’, ‘$address’, ‘$city’, ‘$state’, ‘$zip’, ‘$phone’, ‘$company’, ‘$co_address’, ‘$co_city’, ‘$co_state’, ‘$co_zip’,’$co_phone’, ‘$apache_seminar’,’$docrea_fanclub’,’$geek_seminar’,’$javascript_seminar’,’$php_seminar,’$web_services_seminar’)”;
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
or die(“<p>Unable to execute the query.</p>”
. “<p>Error code ” . mysqli_errno($DBConnect)
. “: ” . mysqli_error($DBConnect)) . “</p>”;
$DBConnect->close(); // closes the database
?>
</body>
</html>