Connecting Tech Pros Worldwide Help | Site Map

submitted form just shows itself

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:37 AM
Norman Bird
Guest
 
Posts: n/a
Default submitted form just shows itself

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("info@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");
}}

?>

  #2  
Old July 17th, 2005, 01:37 AM
Geoff Berrow
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

I noticed that Message-ID:
<1b4c641c.0312121144.6a96effd@posting.google.com > from Norman Bird
contained the following:
[color=blue]
>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.[/color]

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/
  #3  
Old July 17th, 2005, 01:37 AM
Norman Bird
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

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!




info@databaseindays.com (Norman Bird) wrote in message news:<1b4c641c.0312121144.6a96effd@posting.google. com>...[color=blue]
> 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("info@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");
> }}
>
> ?>[/color]
  #4  
Old July 17th, 2005, 01:39 AM
Norman Bird
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

info@databaseindays.com (Norman Bird) wrote in message news:<1b4c641c.0312130713.3702ff49@posting.google. com>...[color=blue]
> 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!
>
>
>[/color]

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("info@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");



} ?>
  #5  
Old July 17th, 2005, 01:39 AM
Geoff Berrow
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

I noticed that Message-ID:
<1b4c641c.0312141125.7f4e3ce4@posting.google.com > from Norman Bird
contained the following:
[color=blue]
>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?[/color]

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/
  #6  
Old July 17th, 2005, 01:39 AM
Geoff Berrow
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

I noticed that Message-ID: <70optvsrr88e1um64mhvk368igjqbvjm89@4ax.com>
from Geoff Berrow contained the following:
[color=blue]
>[color=green]
>>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?[/color]
>
>Don't you have to get the function to return the variable?[/color]

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/
  #7  
Old July 17th, 2005, 01:39 AM
Frank Schummertz
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

Norman Bird wrote:
[color=blue]
> 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?
>[/color]
[color=blue]
> if (isset ($submitbut) ){
> $year = $_POST['yearfield'];
> $month = $_POST['monthfield'];
> $day = $_POST['dayfield'];[/color]

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

  #8  
Old July 17th, 2005, 01:39 AM
Norman Bird
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

Frank Schummertz <frank.schummertz@landseer-stuttgart.de> wrote in message news:<bripvm$t52$1@ulysses.news.tiscali.de>...[color=blue]
> Norman Bird wrote:
>[color=green]
> > 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?
> >[/color]
>[color=green]
> > if (isset ($submitbut) ){
> > $year = $_POST['yearfield'];
> > $month = $_POST['monthfield'];
> > $day = $_POST['dayfield'];[/color]
>
> 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[/color]

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...
  #9  
Old July 17th, 2005, 01:40 AM
Ian.H
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

On Mon, 15 Dec 2003 06:48:40 -0800, Norman Bird wrote:
[color=blue]
> 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...[/color]


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.

  #10  
Old July 17th, 2005, 01:40 AM
Norman Bird
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

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:info@xxx.com">info@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. JSmith@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("info@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();
} ?>
  #11  
Old July 17th, 2005, 01:41 AM
Frank Schummertz
Guest
 
Posts: n/a
Default Re: submitted form just shows itself

Norman Bird wrote:
[color=blue]
> 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...[/color]

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

Frank


--
http://www.pncommerce.de

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.