I have recently been working on a website for an honors association, and have a lot of difficulty but have found help from those on this site. I would like to see if I can get some more help on a different issue than what I was initially having.
I am working on storing data collected from a form on my website. I would like the information to be stored into MySQL once entered by users. I have googled this question and have tried multiple suggestions and have progressed slightly. The problem that I am having is that the page after I press the submit button (actually called Add Member) comes up blank. I would like the page to either read "Thank you, your information has been added" or "Error-incomplete information provided, please fill out the form" or something along those lines.
So my problem is getting the information to store to MySQL and then getting the filled out form page to move onto the next page.
Please see: http://mideasthonors.org/addmember.php to view the form.
This is the scripting I have for the form information to be added to MySQL:
[code=php]
<?php
include ("admintasks-dbcon.php");
mysql_connect($ hostname,$usern ame, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db ($dbname);
$query = 'SELECT * FROM $add_member';
$result = mysql_query($qu ery);
if($result)
{
while($row = mysql_fetch_arr ay($result))
{
$name = $row['$yourfield'];
echo 'Name: '.$name;
mysql_select_db ("mideasthonors ");
$sql="INSERT INTO $add_member (Name, Address 1, Address 2, City, State, Zip Code, Website, Contact Name, Position, Phone Number, Email Address)
VALUES {$_POST['name']},{$_POST['address 1']},{$_POST['address 2']},{$_POST['city']},{$_POST['state']},{$_POST['zip code']},{$_POST['website']},{$_POST['contact name']},{$_POST['position']},{$_POST['phone number']},{$_POST['email address']})";
if (!mysql_query($ sql,$con))
{
die('Error: ' . mysql_error());
}
echo 'Thank You! Your information has been entered into the database!';
}
}
?>
[/code]
This is the error page I have set up:
[code=php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<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>
<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="addmemb er.php" style="width: 169px">
*
<table>
<tr>
<td colspan=2><h2 class="style29" >Institution Information</h2></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='name'>Name *</label></p></td>
<td class="style30" ><input type='text' name='name' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='address_1' >Address*</label></p></td>
<td class="style30" ><input type='text' name='address_1 ' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class="style30" > </td>
<td class="style30" ><input type='text' name='address_2 ' size=45 maxlength=100 /></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 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='state'>Sta te*</label>
<td class="style30" >
<select name='state'>
<?php
$states = array("Illinois ", "Indiana", "Kentucky", "Michigan", "Ohio", "Pennsylvan ia", "Tennessee" , "West Viriginia");
foreach($states as $a => $value){
echo "<option name='$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 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='website'>W ebsite*</label></p></td>
<td class="style30" ><input type='text' name='website' value='http://www.' size=45 maxlength=100 /></td>
</tr>
<tr>
<td colspan=2><h2 class="style29" >Contact Information</h2></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='contact_na me'>Contact Name*</label></p></td>
<td class="style30" ><input type='text' name='contact_n ame' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='contact_po sition'>Positio n</label></p></td>
<td class="style30" ><input type='text' name='contact_p osition' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='contact_ph one'>Phone Number*</label></p></td>
<td class="style30" ><input type='text' name='contact_p hone' size=14 maxlength=14 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='contact_em ail'>Email Address*</label></p></td>
<td class="style30" ><input type='text' name='contact_e mail' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class="style30" > </td>
<td class="style30" ><input type='submit' name ="Add Member" value='Add Member' /></td>
</tr>
</table>
[/code]
If anyone could help me out I would really appreciate it!
I am working on storing data collected from a form on my website. I would like the information to be stored into MySQL once entered by users. I have googled this question and have tried multiple suggestions and have progressed slightly. The problem that I am having is that the page after I press the submit button (actually called Add Member) comes up blank. I would like the page to either read "Thank you, your information has been added" or "Error-incomplete information provided, please fill out the form" or something along those lines.
So my problem is getting the information to store to MySQL and then getting the filled out form page to move onto the next page.
Please see: http://mideasthonors.org/addmember.php to view the form.
This is the scripting I have for the form information to be added to MySQL:
[code=php]
<?php
include ("admintasks-dbcon.php");
mysql_connect($ hostname,$usern ame, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db ($dbname);
$query = 'SELECT * FROM $add_member';
$result = mysql_query($qu ery);
if($result)
{
while($row = mysql_fetch_arr ay($result))
{
$name = $row['$yourfield'];
echo 'Name: '.$name;
mysql_select_db ("mideasthonors ");
$sql="INSERT INTO $add_member (Name, Address 1, Address 2, City, State, Zip Code, Website, Contact Name, Position, Phone Number, Email Address)
VALUES {$_POST['name']},{$_POST['address 1']},{$_POST['address 2']},{$_POST['city']},{$_POST['state']},{$_POST['zip code']},{$_POST['website']},{$_POST['contact name']},{$_POST['position']},{$_POST['phone number']},{$_POST['email address']})";
if (!mysql_query($ sql,$con))
{
die('Error: ' . mysql_error());
}
echo 'Thank You! Your information has been entered into the database!';
}
}
?>
[/code]
This is the error page I have set up:
[code=php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<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>
<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="addmemb er.php" style="width: 169px">
*
<table>
<tr>
<td colspan=2><h2 class="style29" >Institution Information</h2></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='name'>Name *</label></p></td>
<td class="style30" ><input type='text' name='name' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='address_1' >Address*</label></p></td>
<td class="style30" ><input type='text' name='address_1 ' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class="style30" > </td>
<td class="style30" ><input type='text' name='address_2 ' size=45 maxlength=100 /></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 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='state'>Sta te*</label>
<td class="style30" >
<select name='state'>
<?php
$states = array("Illinois ", "Indiana", "Kentucky", "Michigan", "Ohio", "Pennsylvan ia", "Tennessee" , "West Viriginia");
foreach($states as $a => $value){
echo "<option name='$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 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='website'>W ebsite*</label></p></td>
<td class="style30" ><input type='text' name='website' value='http://www.' size=45 maxlength=100 /></td>
</tr>
<tr>
<td colspan=2><h2 class="style29" >Contact Information</h2></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='contact_na me'>Contact Name*</label></p></td>
<td class="style30" ><input type='text' name='contact_n ame' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='contact_po sition'>Positio n</label></p></td>
<td class="style30" ><input type='text' name='contact_p osition' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='contact_ph one'>Phone Number*</label></p></td>
<td class="style30" ><input type='text' name='contact_p hone' size=14 maxlength=14 /></td>
</tr>
<tr>
<td class='style30' ><p class="style31" ><label for='contact_em ail'>Email Address*</label></p></td>
<td class="style30" ><input type='text' name='contact_e mail' size=45 maxlength=100 /></td>
</tr>
<tr>
<td class="style30" > </td>
<td class="style30" ><input type='submit' name ="Add Member" value='Add Member' /></td>
</tr>
</table>
[/code]
If anyone could help me out I would really appreciate it!
Comment