Here is my code, I’m using sessions in order to grab the information. The information prints out on a page but does not send to database but it is connected. CODE:
[code=php]
<?php
session_start(); // allows the sessions to be brought in by starting them
// retrieves the information from the sessions
$_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>
</head>
<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>
<?php
$seminar0 = (!isset($_POST[“seminar[0]”])? NULL: $_POST[“seminar[0]”]);
$seminar1 = (!isset($_POST[“seminar[1]”])? NULL: $_POST[“seminar[1]”]);
$seminar2 = (!isset($_POST[“seminar[2]”])? NULL: $_POST[“seminar[2]”]);
$seminar3 = (!isset($_POST[“seminar[3]”])? NULL: $_POST[“seminar[3]”]);
$seminar4 = (!isset($_POST[“seminar[4]”])? NULL: $_POST[“seminar[4]”]);
$seminar5 = (!isset($_POST[“seminar[5]”])? NULL: $_POST[“seminar[5]”]);
// verifies if fields have been check and the output is below
?>
Apache Seminar<input type=”checkbox” name=”seminar0″ <?php if($seminar0 ==”on”){print ” checked”;?>><br />
DocRea Fanclub<input type=”checkbox” name=”seminar1″ <?php if($seminar1 ==”on”){print ” checked”;?>><br />
Geek Seminar<input type=”checkbox” name=”seminar2″ <?php if($seminar2 ==”on”){print ” checked”;?><br />
Javascript Seminar<input type=”checkbox” name=”seminar3″ <?php if($seminar3 ==”on”){print ” checked”;?><br />
Mysql Seminar<input type=”checkbox” name=”seminar4″ <?php if($seminar4 ==”on”){print ” checked”;?><br />
PHP Seminar<input type=”checkbox” name=”seminar5″ <?php if($seminar5 ==”on”){print ” checked”;?>
</center>
</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) // connecting to the db from name above
or die(“<p>Unable to select the database.</p>”
. “<p>Error code ” . mysqli_errno($DBConnect)
. “: ” . mysqli_error($DBConnect)) . “</p>”; // outputs error messages if unable to connect
$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’];
// sends the data that is received from the sessions to the database and has to stay in same order as database was creatd
$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_servic es_seminar’)”;
// lets you know if your query build was successful or not
$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>