there are also errors on your form and error in sql connection....
e.g.
zip code on your form is named zip and in your php zip code
e.g.
zip code on your form is named zip and in your php zip code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Error</title>
<style type="text/css">
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
}
.style29 {
font-family: Arial, Helvetica, sans-serif;
}
h2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 17px;
font-weight: bold;
color: #2F77F1;
line-height: 20px;
}
.style30 {
font-family: geneva, arial;
font-size: 10pt;
}
.style31 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 11pt;
margin: 3px 0;
padding-bottom: 9px;
}
</style>
</head>
<body>
<?php $memberID = rand(0000000000,9999999999);?>
<p class="style1"><strong>Error: All fields have not been filled in, or information is inaccurate. Please complete form.</strong></p>
<form method="post" action="addmember.php" style="width: 169px">
*<input type="hidden" name="memberID" id="memberID" value="<?php print $memberID;?>" />
<table>
<tr>
<td colspan=2><h2 class="style29">Institution Information</h2></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='name'>Institution*</label></p></td>
<td class="style30"><input type="text" name="institution" size=45 maxlength=100 value="" /></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='address_1'>Address*</label></p></td>
<td class="style30"><input type="text" name="address1" size=45 maxlength=100 value="" /></td>
</tr>
<tr>
<td class="style30"> </td>
<td class="style30"><input type="text" name="address2" size=45 maxlength=100 value="" /></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='city'>City*</label></p></td>
<td class="style30"><input type="text" name="city" size=45 maxlength=50 value="" /></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='state'>State*</label>
<td class="style30">
<select name='state'>
<?php
$states = array("Illinois", "Indiana", "Kentucky", "Michigan", "Ohio", "Pennsylvania", "Tennessee", "West Viriginia");
foreach($states as $a => $value){
echo "<option name=".$value ." value=".$value .">$value</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='zip'>ZIP Code*</label></p></td>
<td class="style30"><input type="text" name="zip" size=10 maxlength=10 value="" /></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='website'>Website*</label></p></td>
<td class="style30"><input type="text" name="website" value="http://www." size=45 maxlength=100 value="" /></td>
</tr>
<tr>
<td colspan=2><h2 class="style29">Contact Information</h2></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='contact_name'>Contact Name*</label></p></td>
<td class="style30"><input type="text" name="contactName" size=45 maxlength=100 value="" /></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='contact_position'>Position</label></p></td>
<td class="style30"><input type="text" name="position" size=45 maxlength=100 value="" /></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='contact_phone'>Phone Number*</label></p></td>
<td class="style30"><input type="text" name="phone" size=14 maxlength=14 value="" /></td>
</tr>
<tr>
<td class='style30'><p class="style31"><label for='contact_email'>Email Address*</label></p></td>
<td class="style30"><input type="text" name="email" size=45 maxlength=100 value="" /></td>
</tr>
<tr>
<td class="style30"> </td>
<td class="style30"><input type="submit" name ="Add Member" value="Add Member" /></td>
</tr>
</table>
<? error_reporting(E_ALL);
include ("admintasks-dbcon.php");
$memberID = $_POST['memberID'];
$institution = $_POST['institution'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zipCode = $_POST['zip'];
$website = $_POST['website'];
$contactName = $_POST['contactName'];
$position = $_POST['position'];
$phoneNumber = $_POST['phone'];
$email = $_POST['email'];
// OPEN CONNECTION --->
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$sql = "SELECT * FROM addMember WHERE email = '{$email}'";
$res = mysql_query( $sql ) or die( mysql_error );
if ( mysql_num_rows( $res ) > 0 )
{
session_start();
$_SESSION["contactName"] = $contactName;
header("location:alreadyMember.php");
}
else{
$query="INSERT addMember (
memberID,
institution,
address1,
address2,
city,
state,
zip,
website,
contactName,
position,
phoneNumber,
email)
VALUES (
'".$memberID."',
'".$institution."',
'".$address1."',
'".$address2."',
'".$city."',
'".$state."',
'".$zipCode."',
'".$website."',
'".$contactName."',
'".$position."',
'".$phoneNumber."',
'".$email."')";
$result=mysql_query($query) or die("Error in query:".mysql_error());
session_start();
$_SESSION["contactName"] = $contactName;
header("location:thankYou.php");
}
mysql_close();
?>
<? session_start(); $contactName = $_SESSION["contactName"]; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> Thank You <?php echo $contactName;?>... You have signed up SUCCESSFULLY! </body> </html>
<? session_start(); $contactName = $_SESSION["contactName"]; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> We're Sorry <?php echo $contactName;?>... But it seems that you are already a member! </body> </html>
-- phpMyAdmin SQL Dump -- version 2.11.9.5 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jul 27, 2009 at 10:47 AM -- Server version: 5.0.77 -- PHP Version: 5.2.6 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `theau10_resources` -- -- -------------------------------------------------------- -- -- Table structure for table `addMember` -- CREATE TABLE IF NOT EXISTS `addMember` ( `id` int(6) NOT NULL auto_increment, `memberID` int(12) NOT NULL, `institution` varchar(45) NOT NULL, `address1` varchar(45) NOT NULL, `address2` varchar(45) NOT NULL, `city` varchar(45) NOT NULL, `state` varchar(2) NOT NULL, `zip` int(10) NOT NULL, `website` text NOT NULL, `contactName` varchar(45) NOT NULL, `position` varchar(25) NOT NULL, `phoneNumber` int(12) NOT NULL, `email` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -- Dumping data for table `addMember` --
<? $hostname="localhost"; $username=""; $password=""; $dbname=""; ?>
Comment