By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

submitted form just shows itself

P: n/a
I have a form i will use to register new people and when I click the
submit button, the form just shows itself. It is supposed to show a
message showing field errors if you leave fields blank etc. so
submitting the empty form should show error message in red , then show
form, but all it does is show form. I checked the variable to make
shore they ere ok and they are fine. i believe it is a logical error
with my if else.... I eved modularized everything by using functions
and the same results.

if any one sees the logical error, let me know. Here the code:
<?php

function showmessage() {
// Check to make sure they entered a valid email address.
if (eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$",
$HTTP_POST_VARS['emailfield'])) {
$d = TRUE;
} else {
$d = FALSE;
$message1[] = "The email address you entered is not valid.";
}
return;
}

function checkfields(){

$year = $HTTP_POST_VARS['yearfield'];
$month = $HTTP_POST_VARS['monthfield'];
$day = $HTTP_POST_VARS['dayfield'];
$dobfield = $year.$month.$day;
// Check the last name.
if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS['usernamefield']))
{
$a = TRUE;
} else {
$a = FALSE;
$message1[] = "Please enter a correct username. I.e; EricDerouen
that consists only of letters.";
}

// Check the first name.
if (eregi ("^([[:alpha:]]|-|')+$",
$HTTP_POST_VARS['firstnamefield'])) {
$b = TRUE;
} else {
$b = FALSE;
$message1[] = "Please enter a First Name that consists only of
letters.";
}

// Check the last name.
if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS['lastnamefield']))
{
$c = TRUE;
} else {
$c = FALSE;
$message1[] = "Please enter a Last Name that consists only of
letters.";
}

// Check to make sure they entered a valid email address.
if (eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$",
$HTTP_POST_VARS['emailfield'])) {
$d = TRUE;
} else {
$d = FALSE;
$message1[] = "The email address you entered is not valid.";
}

// Check the password field.
if ($HTTP_POST_VARS['passwordfield'] <> "") {
$e = TRUE;
} else {
$e = FALSE;
$message1[] = "Please enter a password.";
}

// Check validate password.
if ($HTTP_POST_VARS['confirmfield'] =
$HTTP_POST_VARS['$passwordfield']) {
$f = TRUE;
} else {
$f = FALSE;
$message1[] = "The password you entered do not match the password
you confirmed.";
}

// Check the City.
if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS['cityfield'])) {
$g = TRUE;
} else {
$g = FALSE;
$message1[] = "Please enter a City that consists only of letters.";
}

// Check the state.
if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS['statefield'])) {
$h = TRUE;
} else {
$h = FALSE;
$message1[] = "Please enter a State that consists only of letters.";
}

if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})",$dobfield))
{
$i = TRUE;
} else {
$i = FALSE;
$message1[] = "The BIRTHDATE you entered is invalid.";
}
}

function connectandinsert(){

$hostname = "localhost";
$database = ""; //intentionally left out!
$username = "";
$password = "";

$connection = mysql_connect($hostname, $username, $password) or
die(mysql_error());
$db = mysql_select_db($database, $connection) or die ("could not
connect to database");

//Time to insert variables from form into main table.
$query = "insert into main
(userneme,last,first,dob,attending,email,address,c ity,state,phone,
cellphone,attendedlast,password) values
('$usernamefield','$lastnamefield','$firstnamefiel d','$dobfield','$radiobutton2',
'$emailfield','$addressfield','$cityfield','$state field','$phonefield','$cellphone','$radiobutton3', '$passwordfield')";

$result = mysql_query($query)
or die ("could not execute query.");

}

function sendemails(){
//send email to customer using email he submitted.
$message1 = "{$firstnamefield},\n \nThank you for registering For the
Derouen Family Reunion.\n
You have been pre-registered to attend. A committee member will be
contacting you. \n
You will be also receive the latest Reunion via the E-Mail address
provided.\n
And don't forget to check our family reunion web-site from time to
time.\n \nReunion Committee\n Databaseindays.com";
if (mail($emailfield,"Re: Your Derouen Family Reunion",$message1))
{echo "+";}
else {echo "-";}

//now why not send one to ourself with all the information.
$message1 = "First name: $firstnamefield\nLast Name:
$lastnamefield\nEmail: $emailfield\nPhone: $phonefield\n
cellphone: $cellphone\nDOB: $dobfield\n$Address: $addressfield\n City:
$cityfield\nState: $statefield\nZip: $zipfield\n
Attending: $radiobutton2\nAttended Last: $radiobutton3\n";
if (mail("in**@databaseindays.com","New Registration Form for Derouen
Family Reunion",$message1))
{echo "+";}
else {echo " -";}
}
//************************************************** ********************************
if (!isset($_POST['submitbut']))
{
include("showreg_form.html");
exit;
}

checkfields();
if ($a AND $b AND $c AND $d AND $e AND $f AND $g AND $h AND $i)
{
connectandinsert();
sendemails();
echo "all went well. inserted and emailed your ass";
}
else
{
showmessage();
include("showreg_form.html");
}}

?>
Jul 17 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
I noticed that Message-ID:
<1b**************************@posting.google.com > from Norman Bird
contained the following:
I have a form i will use to register new people and when I click the
submit button, the form just shows itself. It is supposed to show a
message showing field errors if you leave fields blank etc.


I'm no expert but I can't see a print or echo for the field errors.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
It would appears that you have pointed out a material error. When I
modularized the code, I put the email check code in the showmessage
area. this is wrong. Thank you. I will fix and keep everyone posted. I
looked over this code for day and i did not see this. Goes to show
you, sometimes you just need a new pair of eyes to look at the code.
At one point I had it right, but as I tried to fix another area , this
crept in. Thanks a lot buddy!


in**@databaseindays.com (Norman Bird) wrote in message news:<1b**************************@posting.google. com>...
I have a form i will use to register new people and when I click the
submit button, the form just shows itself. It is supposed to show a
message showing field errors if you leave fields blank etc. so
submitting the empty form should show error message in red , then show
form, but all it does is show form. I checked the variable to make
shore they ere ok and they are fine. i believe it is a logical error
with my if else.... I eved modularized everything by using functions
and the same results.

if any one sees the logical error, let me know. Here the code:
<?php

function showmessage() {
// Check to make sure they entered a valid email address.
if (eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$",
$HTTP_POST_VARS['emailfield'])) {
$d = TRUE;
} else {
$d = FALSE;
$message1[] = "The email address you entered is not valid.";
}
return;
}

function checkfields(){

$year = $HTTP_POST_VARS['yearfield'];
$month = $HTTP_POST_VARS['monthfield'];
$day = $HTTP_POST_VARS['dayfield'];
$dobfield = $year.$month.$day;
// Check the last name.
if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS['usernamefield']))
{
$a = TRUE;
} else {
$a = FALSE;
$message1[] = "Please enter a correct username. I.e; EricDerouen
that consists only of letters.";
}

// Check the first name.
if (eregi ("^([[:alpha:]]|-|')+$",
$HTTP_POST_VARS['firstnamefield'])) {
$b = TRUE;
} else {
$b = FALSE;
$message1[] = "Please enter a First Name that consists only of
letters.";
}

// Check the last name.
if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS['lastnamefield']))
{
$c = TRUE;
} else {
$c = FALSE;
$message1[] = "Please enter a Last Name that consists only of
letters.";
}

// Check to make sure they entered a valid email address.
if (eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$",
$HTTP_POST_VARS['emailfield'])) {
$d = TRUE;
} else {
$d = FALSE;
$message1[] = "The email address you entered is not valid.";
}

// Check the password field.
if ($HTTP_POST_VARS['passwordfield'] <> "") {
$e = TRUE;
} else {
$e = FALSE;
$message1[] = "Please enter a password.";
}

// Check validate password.
if ($HTTP_POST_VARS['confirmfield'] =
$HTTP_POST_VARS['$passwordfield']) {
$f = TRUE;
} else {
$f = FALSE;
$message1[] = "The password you entered do not match the password
you confirmed.";
}

// Check the City.
if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS['cityfield'])) {
$g = TRUE;
} else {
$g = FALSE;
$message1[] = "Please enter a City that consists only of letters.";
}

// Check the state.
if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS['statefield'])) {
$h = TRUE;
} else {
$h = FALSE;
$message1[] = "Please enter a State that consists only of letters.";
}

if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})",$dobfield))
{
$i = TRUE;
} else {
$i = FALSE;
$message1[] = "The BIRTHDATE you entered is invalid.";
}
}

function connectandinsert(){

$hostname = "localhost";
$database = ""; //intentionally left out!
$username = "";
$password = "";

$connection = mysql_connect($hostname, $username, $password) or
die(mysql_error());
$db = mysql_select_db($database, $connection) or die ("could not
connect to database");

//Time to insert variables from form into main table.
$query = "insert into main
(userneme,last,first,dob,attending,email,address,c ity,state,phone,
cellphone,attendedlast,password) values
('$usernamefield','$lastnamefield','$firstnamefiel d','$dobfield','$radiobutton2',
'$emailfield','$addressfield','$cityfield','$state field','$phonefield','$cellphone','$radiobutton3', '$passwordfield')";

$result = mysql_query($query)
or die ("could not execute query.");

}

function sendemails(){
//send email to customer using email he submitted.
$message1 = "{$firstnamefield},\n \nThank you for registering For the
Derouen Family Reunion.\n
You have been pre-registered to attend. A committee member will be
contacting you. \n
You will be also receive the latest Reunion via the E-Mail address
provided.\n
And don't forget to check our family reunion web-site from time to
time.\n \nReunion Committee\n Databaseindays.com";
if (mail($emailfield,"Re: Your Derouen Family Reunion",$message1))
{echo "+";}
else {echo "-";}

//now why not send one to ourself with all the information.
$message1 = "First name: $firstnamefield\nLast Name:
$lastnamefield\nEmail: $emailfield\nPhone: $phonefield\n
cellphone: $cellphone\nDOB: $dobfield\n$Address: $addressfield\n City:
$cityfield\nState: $statefield\nZip: $zipfield\n
Attending: $radiobutton2\nAttended Last: $radiobutton3\n";
if (mail("in**@databaseindays.com","New Registration Form for Derouen
Family Reunion",$message1))
{echo "+";}
else {echo " -";}
}
//************************************************** ********************************
if (!isset($_POST['submitbut']))
{
include("showreg_form.html");
exit;
}

checkfields();
if ($a AND $b AND $c AND $d AND $e AND $f AND $g AND $h AND $i)
{
connectandinsert();
sendemails();
echo "all went well. inserted and emailed your ass";
}
else
{
showmessage();
include("showreg_form.html");
}}

?>

Jul 17 '05 #3

P: n/a
in**@databaseindays.com (Norman Bird) wrote in message news:<1b**************************@posting.google. com>...
It would appears that you have pointed out a material error. When I
modularized the code, I put the email check code in the showmessage
area. this is wrong. Thank you. I will fix and keep everyone posted. I
looked over this code for day and i did not see this. Goes to show
you, sometimes you just need a new pair of eyes to look at the code.
At one point I had it right, but as I tried to fix another area , this
crept in. Thanks a lot buddy!


I fixed that mistake below is the new code that still doesnot work.
anymore eyes see the problem why the errors dont show befor the form
is displayed?

<?php
//************************************************** ********************************

function connectdb(){
$hostname = "localhost";
$database = "";
$username = "";
$password = "";

$connection = mysql_connect($hostname, $username, $password) or
die(mysql_error());
$db = mysql_select_db($database, $connection) or die ("could not
connect to database");

}

if (isset ($submitbut) ){
$year = $_POST['yearfield'];
$month = $_POST['monthfield'];
$day = $_POST['dayfield'];
$dobfield = $year.$month.$day;
// Check the last name.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['usernamefield'])) {
$a = TRUE;
} else {
$a = FALSE;
$message1[] = "Please enter a correct username. I.e; EricDerouen
that consists only of letters.";

}

// Check the first name.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['firstnamefield'])) {
$b = TRUE;
} else {
$b = FALSE;
$message1[] = "Please enter a First Name that consists only of
letters.";

}

// Check the last name.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['lastnamefield'])) {
$c = TRUE;
} else {
$c = FALSE;
$message1[] = "Please enter a Last Name that consists only of
letters.";
}

// Check to make sure they entered a valid email address.
if (eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$",
$_POST['emailfield'])) {
$d = TRUE;
} else {
$d = FALSE;
$message1[] = "The email address you entered is not valid.";
}

// Check the password field.
if ($_POST['passwordfield'] <> "") {
$e = TRUE;
} else {
$e = FALSE;
$message1[] = "Please enter a password.";
}

// Check validate password.
if ($_POST['confirmfield'] = $_POST['$passwordfield']) {
$f = TRUE;
} else {
$f = FALSE;
$message1[] = "The password you entered do not match the password
you confirmed.";
}

// Check the City.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['cityfield'])) {
$g = TRUE;
} else {
$g = FALSE;
$message1[] = "Please enter a City that consists only of letters.";
}

// Check the state.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['statefield'])) {
$h = TRUE;
} else {
$h = FALSE;
$message1[] = "Please enter a State that consists only of letters.";
}

if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})",$dobfield))
{
$i = TRUE;
} else {
$i = FALSE;
$message1[] = "The BIRTHDATE you entered is invalid.";
}

if ($a and $b and $c and $d and $e and $f and $g and $h and $i)
{
connectdb();

//Time to insert variables from form into main table.
$query = "insert into main
(userneme,last,first,dob,attending,email,address,c ity,state,phone,
cellphone,attendedlast,password) values
('$usernamefield','$lastnamefield','$firstnamefiel d','$dobfield','$radiobutton2',
'$emailfield','$addressfield','$cityfield','$state field','$phonefield','$cellphone','$radiobutton3', '$passwordfield')";

$result = mysql_query($query)
or die ("could not execute query.");

$message = "{$firstnamefield},\n \nThank you for registering For the
Derouen Family Reunion.\n
You have been pre-registered to attend. A committee member will be
contacting you. \n
You will be also receive the latest Reunion via the E-Mail address
provided.\n
And don't forget to check our family reunion web-site from time to
time.\n \nReunion Committee\n Databaseindays.com";
if (mail($emailfield,"Re: Your Derouen Family Reunion",$message1))
{echo "+";}
else {echo "-";}

//now why not send one to ourself with all the information.
$message = "First name: $firstnamefield\nLast Name:
$lastnamefield\nEmail: $emailfield\nPhone: $phonefield\n
cellphone: $cellphone\nDOB: $dobfield\n$Address: $addressfield\n City:
$cityfield\nState: $statefield\nZip: $zipfield\n
Attending: $radiobutton2\nAttended Last: $radiobutton3\n";
if (mail("in**@databaseindays.com","New Registration Form for Derouen
Family Reunion",$message1))
{echo "+";}
else {echo " -";}

echo "all went well. inserted and emailed your ass";

if ($message1) {
echo "<div align=\"center\"><font color=red><b>The following problems
occurred:</b><br />\n";
foreach ($message1 as $key => $value) {
echo "$value <br />\n";
}
include("showreg_form.html");
}
}}
else
{

include("showreg_form.html");

} ?>
Jul 17 '05 #4

P: n/a
I noticed that Message-ID:
<1b**************************@posting.google.com > from Norman Bird
contained the following:
I fixed that mistake below is the new code that still doesnot work.
anymore eyes see the problem why the errors dont show befor the form
is displayed?


Don't you have to get the function to return the variable?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5

P: n/a
I noticed that Message-ID: <70********************************@4ax.com>
from Geoff Berrow contained the following:
I fixed that mistake below is the new code that still doesnot work.
anymore eyes see the problem why the errors dont show befor the form
is displayed?


Don't you have to get the function to return the variable?


Ignore that - I noticed you got rid of the functions

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6

P: n/a
Norman Bird wrote:
I fixed that mistake below is the new code that still doesnot work.
anymore eyes see the problem why the errors dont show befor the form
is displayed?
if (isset ($submitbut) ){
$year = $_POST['yearfield'];
$month = $_POST['monthfield'];
$day = $_POST['dayfield'];


I think the submit button is named submitbut, right? So if you want to
use the varaible $submitbut you should read it with

$submitbut = $_POST['submitbut'];

before as you do it with the other variables.
Frank

--
http://www.pncommerce.de

Jul 17 '05 #7

P: n/a
Frank Schummertz <fr**************@landseer-stuttgart.de> wrote in message news:<br**********@ulysses.news.tiscali.de>...
Norman Bird wrote:
I fixed that mistake below is the new code that still doesnot work.
anymore eyes see the problem why the errors dont show befor the form
is displayed?

if (isset ($submitbut) ){
$year = $_POST['yearfield'];
$month = $_POST['monthfield'];
$day = $_POST['dayfield'];


I think the submit button is named submitbut, right? So if you want to
use the varaible $submitbut you should read it with

$submitbut = $_POST['submitbut'];

before as you do it with the other variables.
Frank


I actually don't think so. once the form is submitted , the variable
is available. I also used the popular method of :

if (isset($_post['submitbut']))
and that did not work either. I think its the way I do the if..else...
Jul 17 '05 #8

P: n/a
On Mon, 15 Dec 2003 06:48:40 -0800, Norman Bird wrote:
I actually don't think so. once the form is submitted , the variable is
available. I also used the popular method of :

if (isset($_post['submitbut']))
and that did not work either. I think its the way I do the if..else...

Norman,

Stupid question maybe, but I couldn't see any form code available here...
you have got the submit button name defined haven't you?:
<input type="submit" name="submitbut" value="Submit" />
for example?

Just a thought =)

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

Jul 17 '05 #9

P: n/a
I finally got the registration form to work. Code is below. It is
actually a good example to use to register people. I believe my
problem was the fact that I showed the form using an
"include(showform.php)". Since I had the form calling itself if there
was a problem, this caused a problem showing the errors. Once I
included the code to show form all in the same script, this made
everything fire like it was supposed to. This script displays a form
and checks the fields for valid info then inserts into a DB then
amails the user his registration info then emails you a new person
registered than thanks the user. thanks to all tha helped:

<?php
//************************************************** ********************************
function thankyou(){
?>
<html>
<body bgcolor="#FFFFFF">
<div align="center"><font color="#669933" size="6" face="Comic Sans
MS">Thank
you </font> </div>
<p align="center"><font color="#669933" size="4" face="Comic Sans
MS">for registering
for the website.<br>
You will soon receive an email confirmation of your
registration.<br>
You can login to the site now using the username and password you
provided.<br>
A committee member will also be contacting you.
</font></p>
<h3 align="center">&nbsp;</h3>
<h3 align="center">Email us at: <a
href="mailto:in**@xxx.com">in**@xxx.Com</a></h3>
<p align="center"><font size="4"> | <a href="login.php">Login
</a>&nbsp; | <a href="index.html">Home</a> |</font></p>
</body>
</html>
<?php

}
function connectdb(){
$hostname = "localhost";
$database = "xxx";
$username = "xxx";
$password = "xxx";

$connection = mysql_connect($hostname, $username, $password) or
die(mysql_error());
$db = mysql_select_db($database, $connection) or die ("could not
connect to database");

}

function showform(){
?>
<html>
<head>
<title>Register to the Derouen Family Web-Site</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0">
<form name="form2" method="post" action= "register.php" >
<table width="90%" border="0" cellpadding="8" bgcolor="#FFFFFF">
<tr>
<td colspan="3" bgcolor="#CCCCCC">
<b>Register for the xxx </b></td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC" nowrap>
User Name<font size="-2">*</font></td>
<td colspan="2" bgcolor="#FFFFFF"> <input
name="usernamefield" type="text" id="usernamefield" size="25"
maxlength="25" value="<?php echo $usernamefield ?>">
<br>
<font size="-2">*</font>Enter a user name.
Ex.&nbsp;&nbsp;&nbsp;&nbsp; xxx <font size="-1">&nbsp; </font></td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
Password<font size="-2">*</font></td>
<td colspan="2" bgcolor="#FFFFFF"> <input
name="passwordfield" type="password" id="passwordfield" size="25"
maxlength="25"> </td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
Confirm<br>
Password</td>
<td colspan="2" bgcolor="#FFFFFF"> <input
name="confirmfield" type="password" id="confirmfield" size="25"
maxlength="25">
<br>
<font size="-2">*</font><font size="-1">Confirm the password
you entered </font></td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
Name</td>
<td width="43%" bgcolor="#FFFFFF"> <input
name="firstnamefield" type="text" id="firstnamefield" size="25"
maxlength="25" value="<?php echo $firstnamefield ?>">
<br> <font size="-1">First</font></td>
<td width="46%" bgcolor="#FFFFFF"> <input
name="lastnamefield" type="text" id="lastnamefield" size="25"
maxlength="25" value="<?php echo $lastnamefield ?>">
<br> <font size="-1">Last</font></td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
Email</td>
<td colspan="2" bgcolor="#FFFFFF"> <input
name="emailfield" type="text" id="emailfield" size="50" maxlength="50"
value="<?php echo $emailfield ?>">
Ex. JS****@Comcast.net </td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
Phone</td>
<td colspan="2" bgcolor="#FFFFFF"><input name="phonefield"
type="text" id="phonefield" size="15" maxlength="15" value="<?php echo
$phonefield ?>">
&nbsp;&nbsp;Cell Phone
<input name="cellphonefield" type="text" id="cellphonefield"
size="15" maxlength="15" value="<?php echo $cellphonefield ?>">
</td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
Address</td>
<td colspan="2" bgcolor="#FFFFFF"> <input
name="addressfield" type="text" id="addressfield" size="50"
maxlength="50" value="<?php echo $addressfield ?>">
</td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
City/State/Zip</td>
<td colspan="2" bgcolor="#FFFFFF"> <input
name="cityfield" type="text" id="cityfield" size="25" maxlength="25"
value="<?php echo $cityfield ?>">
&nbsp; State:
<input name="statefield" type="text" id="statefield" size="2"
maxlength="2" value="<?php echo $statefield ?>">
&nbsp; Zip:
<input name="zipcodefield" type="text" id="zipcodefield"
size="10" maxlength="10" value="<?php echo $zipcodefield ?>">
</td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
Gender</td>
<td colspan="2" bgcolor="#FFFFFF"> <p>
<input type="radio" name="radiobutton1" value="male">
Male
<input type="radio" name="radiobutton1" value="female">
Female </p></td>
</tr>
<tr valign="top">
<td align="right" bgcolor="#CCCCCC">
Birth Date</td>
<td colspan="2" bgcolor="#FFFFFF"> <table border="0"
cellspacing="2" cellpadding="0">
<tr align="left">
<td><input name="monthfield" type="text"
id="monthfield" size="2" maxlength="2"></td>
<td><input name="dayfield" type="text" id="dayfield"
size="2" maxlength="2"></td>
<td><input name="yearfield" type="text" id="yearfield"
size="4" maxlength="4"></td>
</tr>
<tr align="left">
<td>MM</td>
<td>DD</td>
<td>YYYY</td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td colspan="3"> <p>Do you plan on attending the next
?.<br>
<input type="radio" name="radiobutton2" value="yes">
Yes<br>
<input type="radio" name="radiobutton2" value="no">
No</p>
<p>Did you attend the last Reunion?. <br>
<input type="radio" name="radiobutton3" value="yes">
Yes<br>
<input type="radio" name="radiobutton3" value="no">
No</p></td>
</tr>
<tr valign="top" bgcolor="#FFFFFF">
<td colspan="3"><input type="submit" name="submitbut"
value="Submit Registration Information"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
if (isset ($_POST['submitbut'])){
//echo "but is set";
$year = $_POST['yearfield'];
$month = $_POST['monthfield'];
$day = $_POST['dayfield'];
$dobfield = $year.'-'.$month.'-'.$day;
//echo "this is the date : $dobfield";
//exit;
// Check the last name.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['usernamefield'])) {
$a = TRUE;
} else {
$a = FALSE;
$message1[] = "Please enter a correct username. I.e; EricDerouen
that consists only of letters.";

}

// Check the first name.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['firstnamefield'])) {
$b = TRUE;
} else {
$b = FALSE;
$message1[] = "Please enter a First Name that consists only of
letters.";

}

// Check the last name.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['lastnamefield'])) {
$c = TRUE;
} else {
$c = FALSE;
$message1[] = "Please enter a Last Name that consists only of
letters.";
}

// Check to make sure they entered a valid email address.
if (eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$",
$_POST['emailfield'])) {
$d = TRUE;
} else {
$d = FALSE;
$message1[] = "The email address you entered is not valid.";
}

// Check the password field.
if ($_POST['passwordfield'] <> "") {
$e = TRUE;
} else {
$e = FALSE;
$message1[] = "Please enter a password.";
}

// Check validate password.
if ($_POST[confirmfield] = $_POST['passwordfield']) {
$f = TRUE;
} else {
$f = FALSE;
$message1[] = "The password you entered do not match the password
you confirmed.";
}

// Check the City.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['cityfield'])) {
$g = TRUE;
} else {
$g = FALSE;
$message1[] = "Please enter a City that consists only of letters.";
}

// Check the state.
if (eregi ("^([[:alpha:]]|-|')+$", $_POST['statefield'])) {
$h = TRUE;
} else {
$h = FALSE;
$message1[] = "Please enter a State that consists only of letters.";
}

if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})",$dobfield))
{
$i = TRUE;
} else {
$i = FALSE;
$message1[] = "The BIRTHDATE you entered is invalid.";
}}

if ($a and $b and $c and $d and $e and $f and $g and $h and $i)
{

connectdb();

//Time to insert variables from form into main table.
$query = "insert into main
(username,last,first,dob,attending,email,address,c ity,state,zip,phone,
cellphone,attendedlast,password) values
('$usernamefield','$lastnamefield','$firstnamefiel d','$dobfield','$radiobutton2',
'$emailfield','$addressfield','$cityfield','$state field','$zipcodefield','$phonefield','$cellphone', '$radiobutton3','$passwordfield')";

$result = mysql_query($query)
or die ("could not execute query.");

$message = "{$firstnamefield},\n \nThank you for registering For the
Reunion.\n
You have been pre-registered to attend. A committee member will be
contacting you. \n
You will also receive the latest Reunion information via the E-Mail
address provided.\n
And don't forget to check our family reunion web-site from time to
time.\n
Your userid is: $username\nYour password is $passwordfield\n
\nReunion 2004 Committee.\n <a href="www.xxx.com/login.php">Login
Here</a>";
if (mail($emailfield,"Re: Your Reunion",$message))
{echo "+";}
else {echo "-";}

//now why not send one to ourself with all the information.
$message = "Username: $usernamefield\nFirst name:
$firstnamefield\nLast Name: $lastnamefield\nEmail: $emailfield\nPhone:
$phonefield
cellphone: $cellphonefield\nDOB: $dobfield\nAddress:
$addressfield\nCity: $cityfield\nState: $statefield\nZip:
$zipcodefield
Attending: $radiobutton2\nAttended Last: $radiobutton3\n
Username: $usernamefield";
if (mail("in**@xxx.com","New Registration Form for Reunion",$message))
{echo "+";}
else {echo " -";}

thankyou();
}
else
{
//echo "some fields are wrong";
if ($message1) {
echo "<div align=center><font color=red><b>The following problems
occurred:</b><br />\n";
foreach ($message1 as $key => $value) {
echo "$value <br />\n";
}

}
showform();
} ?>
Jul 17 '05 #10

P: n/a
Norman Bird wrote:
I actually don't think so. once the form is submitted , the variable
is available. I also used the popular method of :

if (isset($_post['submitbut']))
and that did not work either. I think its the way I do the if..else...


$_post <> $_POST, please take care of this!

Frank
--
http://www.pncommerce.de

Jul 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.