submitted form just shows itself

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Norman Bird

    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.$d ay;
    // 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_VAR S['passwordfield'] <> "") {
    $e = TRUE;
    } else {
    $e = FALSE;
    $message1[] = "Please enter a password.";
    }

    // Check validate password.
    if ($HTTP_POST_VAR S['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 connectandinser t(){

    $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,atten ding,email,addr ess,city,state, phone,
    cellphone,atten dedlast,passwor d) values
    ('$usernamefiel d','$lastnamefi eld','$firstnam efield','$dobfi eld','$radiobut ton2',
    '$emailfield',' $addressfield', '$cityfield','$ statefield','$p honefield','$ce llphone','$radi obutton3','$pas swordfield')";

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

    }

    function sendemails(){
    //send email to customer using email he submitted.
    $message1 = "{$firstnamefie ld},\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($emailfie ld,"Re: Your Derouen Family Reunion",$messa ge1))
    {echo "+";}
    else {echo "-";}

    //now why not send one to ourself with all the information.
    $message1 = "First name: $firstnamefield \nLast Name:
    $lastnamefield\ nEmail: $emailfield\nPh one: $phonefield\n
    cellphone: $cellphone\nDOB : $dobfield\n$Add ress: $addressfield\n City:
    $cityfield\nSta te: $statefield\nZi p: $zipfield\n
    Attending: $radiobutton2\n Attended Last: $radiobutton3\n ";
    if (mail("info@dat abaseindays.com ","New Registration Form for Derouen
    Family Reunion",$messa ge1))
    {echo "+";}
    else {echo " -";}
    }
    //*************** *************** *************** *************** *************** *******
    if (!isset($_POST['submitbut']))
    {
    include("showre g_form.html");
    exit;
    }

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

    ?>
  • Geoff Berrow

    #2
    Re: submitted form just shows itself

    I noticed that Message-ID:
    <1b4c641c.03121 21144.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/

    Comment

    • Norman Bird

      #3
      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@databasein days.com (Norman Bird) wrote in message news:<1b4c641c. 0312121144.6a96 effd@posting.go ogle.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.$d ay;
      > // 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_VAR S['passwordfield'] <> "") {
      > $e = TRUE;
      > } else {
      > $e = FALSE;
      > $message1[] = "Please enter a password.";
      > }
      >
      > // Check validate password.
      > if ($HTTP_POST_VAR S['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 connectandinser t(){
      >
      > $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,atten ding,email,addr ess,city,state, phone,
      > cellphone,atten dedlast,passwor d) values
      > ('$usernamefiel d','$lastnamefi eld','$firstnam efield','$dobfi eld','$radiobut ton2',
      > '$emailfield',' $addressfield', '$cityfield','$ statefield','$p honefield','$ce llphone','$radi obutton3','$pas swordfield')";
      >
      > $result = mysql_query($qu ery)
      > or die ("could not execute query.");
      >
      > }
      >
      > function sendemails(){
      > //send email to customer using email he submitted.
      > $message1 = "{$firstnamefie ld},\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($emailfie ld,"Re: Your Derouen Family Reunion",$messa ge1))
      > {echo "+";}
      > else {echo "-";}
      >
      > //now why not send one to ourself with all the information.
      > $message1 = "First name: $firstnamefield \nLast Name:
      > $lastnamefield\ nEmail: $emailfield\nPh one: $phonefield\n
      > cellphone: $cellphone\nDOB : $dobfield\n$Add ress: $addressfield\n City:
      > $cityfield\nSta te: $statefield\nZi p: $zipfield\n
      > Attending: $radiobutton2\n Attended Last: $radiobutton3\n ";
      > if (mail("info@dat abaseindays.com ","New Registration Form for Derouen
      > Family Reunion",$messa ge1))
      > {echo "+";}
      > else {echo " -";}
      > }
      > //*************** *************** *************** *************** *************** *******
      > if (!isset($_POST['submitbut']))
      > {
      > include("showre g_form.html");
      > exit;
      > }
      >
      > checkfields();
      > if ($a AND $b AND $c AND $d AND $e AND $f AND $g AND $h AND $i)
      > {
      > connectandinser t();
      > sendemails();
      > echo "all went well. inserted and emailed your ass";
      > }
      > else
      > {
      > showmessage();
      > include("showre g_form.html");
      > }}
      >
      > ?>[/color]

      Comment

      • Norman Bird

        #4
        Re: submitted form just shows itself

        info@databasein days.com (Norman Bird) wrote in message news:<1b4c641c. 0312130713.3702 ff49@posting.go ogle.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.$d ay;
        // 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,atten ding,email,addr ess,city,state, phone,
        cellphone,atten dedlast,passwor d) values
        ('$usernamefiel d','$lastnamefi eld','$firstnam efield','$dobfi eld','$radiobut ton2',
        '$emailfield',' $addressfield', '$cityfield','$ statefield','$p honefield','$ce llphone','$radi obutton3','$pas swordfield')";

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

        $message = "{$firstnamefie ld},\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($emailfie ld,"Re: Your Derouen Family Reunion",$messa ge1))
        {echo "+";}
        else {echo "-";}

        //now why not send one to ourself with all the information.
        $message = "First name: $firstnamefield \nLast Name:
        $lastnamefield\ nEmail: $emailfield\nPh one: $phonefield\n
        cellphone: $cellphone\nDOB : $dobfield\n$Add ress: $addressfield\n City:
        $cityfield\nSta te: $statefield\nZi p: $zipfield\n
        Attending: $radiobutton2\n Attended Last: $radiobutton3\n ";
        if (mail("info@dat abaseindays.com ","New Registration Form for Derouen
        Family Reunion",$messa ge1))
        {echo "+";}
        else {echo " -";}

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

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


        }}
        else
        {

        include("showre g_form.html");



        } ?>

        Comment

        • Geoff Berrow

          #5
          Re: submitted form just shows itself

          I noticed that Message-ID:
          <1b4c641c.03121 41125.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/

          Comment

          • Geoff Berrow

            #6
            Re: submitted form just shows itself

            I noticed that Message-ID: <70optvsrr88e1u m64mhvk368igjqb vjm89@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/

            Comment

            • Frank Schummertz

              #7
              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

              --


              Comment

              • Norman Bird

                #8
                Re: submitted form just shows itself

                Frank Schummertz <frank.schummer tz@landseer-stuttgart.de> wrote in message news:<bripvm$t5 2$1@ulysses.new s.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...

                Comment

                • Ian.H

                  #9
                  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.ne t | forum.digiserv. net
                  Programming, Web design, development & hosting.

                  Comment

                  • Norman Bird

                    #10
                    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(showfo rm.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="#FFFFF F">
                    <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.<b r>
                    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 fo@xxx.com">inf o@xxx.Com</a></h3>
                    <p align="center"> <font size="4"> | <a href="login.php ">Login
                    </a>&nbsp; | <a href="index.htm l">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>Regist er to the Derouen Family Web-Site</title>
                    <meta http-equiv="Content-Type" content="text/html;
                    charset=iso-8859-1">
                    </head>
                    <body bgcolor="#FFFFF F" leftmargin="0" topmargin="0" marginwidth="0"
                    marginheight="0 ">
                    <form name="form2" method="post" action= "register.p hp" >
                    <table width="90%" border="0" cellpadding="8" bgcolor="#FFFFF F">
                    <tr>
                    <td colspan="3" bgcolor="#CCCCC C">
                    <b>Register for the xxx </b></td>
                    </tr>
                    <tr valign="top">
                    <td align="right" bgcolor="#CCCCC C" nowrap>
                    User Name<font size="-2">*</font></td>
                    <td colspan="2" bgcolor="#FFFFF F"> <input
                    name="usernamef ield" type="text" id="usernamefie ld" 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="#CCCCC C">
                    Password<font size="-2">*</font></td>
                    <td colspan="2" bgcolor="#FFFFF F"> <input
                    name="passwordf ield" type="password" id="passwordfie ld" size="25"
                    maxlength="25"> </td>
                    </tr>
                    <tr valign="top">
                    <td align="right" bgcolor="#CCCCC C">
                    Confirm<br>
                    Password</td>
                    <td colspan="2" bgcolor="#FFFFF F"> <input
                    name="confirmfi eld" type="password" id="confirmfiel d" 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="#CCCCC C">
                    Name</td>
                    <td width="43%" bgcolor="#FFFFF F"> <input
                    name="firstname field" type="text" id="firstnamefi eld" size="25"
                    maxlength="25" value="<?php echo $firstnamefield ?>">
                    <br> <font size="-1">First</font></td>
                    <td width="46%" bgcolor="#FFFFF F"> <input
                    name="lastnamef ield" type="text" id="lastnamefie ld" size="25"
                    maxlength="25" value="<?php echo $lastnamefield ?>">
                    <br> <font size="-1">Last</font></td>
                    </tr>
                    <tr valign="top">
                    <td align="right" bgcolor="#CCCCC C">
                    Email</td>
                    <td colspan="2" bgcolor="#FFFFF F"> <input
                    name="emailfiel d" 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="#CCCCC C">
                    Phone</td>
                    <td colspan="2" bgcolor="#FFFFF F"><input name="phonefiel d"
                    type="text" id="phonefield " size="15" maxlength="15" value="<?php echo
                    $phonefield ?>">
                    &nbsp;&nbsp;Cel l Phone
                    <input name="cellphone field" type="text" id="cellphonefi eld"
                    size="15" maxlength="15" value="<?php echo $cellphonefield ?>">
                    </td>
                    </tr>
                    <tr valign="top">
                    <td align="right" bgcolor="#CCCCC C">
                    Address</td>
                    <td colspan="2" bgcolor="#FFFFF F"> <input
                    name="addressfi eld" type="text" id="addressfiel d" size="50"
                    maxlength="50" value="<?php echo $addressfield ?>">
                    </td>
                    </tr>
                    <tr valign="top">
                    <td align="right" bgcolor="#CCCCC C">
                    City/State/Zip</td>
                    <td colspan="2" bgcolor="#FFFFF F"> <input
                    name="cityfield " type="text" id="cityfield" size="25" maxlength="25"
                    value="<?php echo $cityfield ?>">
                    &nbsp; State:
                    <input name="statefiel d" type="text" id="statefield " size="2"
                    maxlength="2" value="<?php echo $statefield ?>">
                    &nbsp; Zip:
                    <input name="zipcodefi eld" type="text" id="zipcodefiel d"
                    size="10" maxlength="10" value="<?php echo $zipcodefield ?>">
                    </td>
                    </tr>
                    <tr valign="top">
                    <td align="right" bgcolor="#CCCCC C">
                    Gender</td>
                    <td colspan="2" bgcolor="#FFFFF F"> <p>
                    <input type="radio" name="radiobutt on1" value="male">
                    Male
                    <input type="radio" name="radiobutt on1" value="female">
                    Female </p></td>
                    </tr>
                    <tr valign="top">
                    <td align="right" bgcolor="#CCCCC C">
                    Birth Date</td>
                    <td colspan="2" bgcolor="#FFFFF F"> <table border="0"
                    cellspacing="2" cellpadding="0" >
                    <tr align="left">
                    <td><input name="monthfiel d" 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="radiobutt on2" value="yes">
                    Yes<br>
                    <input type="radio" name="radiobutt on2" value="no">
                    No</p>
                    <p>Did you attend the last Reunion?. <br>
                    <input type="radio" name="radiobutt on3" value="yes">
                    Yes<br>
                    <input type="radio" name="radiobutt on3" value="no">
                    No</p></td>
                    </tr>
                    <tr valign="top" bgcolor="#FFFFF F">
                    <td colspan="3"><in put 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,atten ding,email,addr ess,city,state, zip,phone,
                    cellphone,atten dedlast,passwor d) values
                    ('$usernamefiel d','$lastnamefi eld','$firstnam efield','$dobfi eld','$radiobut ton2',
                    '$emailfield',' $addressfield', '$cityfield','$ statefield','$z ipcodefield','$ phonefield','$c ellphone','$rad iobutton3','$pa sswordfield')";

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

                    $message = "{$firstnamefie ld},\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.c om/login.php">Logi n
                    Here</a>";
                    if (mail($emailfie ld,"Re: Your Reunion",$messa ge))
                    {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\nPh one:
                    $phonefield
                    cellphone: $cellphonefield \nDOB: $dobfield\nAddr ess:
                    $addressfield\n City: $cityfield\nSta te: $statefield\nZi p:
                    $zipcodefield
                    Attending: $radiobutton2\n Attended Last: $radiobutton3\n
                    Username: $usernamefield" ;
                    if (mail("info@xxx .com","New Registration Form for Reunion",$messa ge))
                    {echo "+";}
                    else {echo " -";}

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

                    }
                    showform();
                    } ?>

                    Comment

                    • Frank Schummertz

                      #11
                      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


                      --


                      Comment

                      Working...