Warn by leaving a form view with unsaved changes

Hello JSF / Richfaces users,
maybe that's not the first time, that someone asks this question here, but unfortunately I couldn't found any concrete examples on the forum. So I'd like really to get your help:
I'd like to put some "input listeners" on my form views, so that when the user makes changes (typing in inputText, selection another value in selectMenu or checking a Checkbox), then he clicks on another Button / Link without saving, he shoudl will be warned by a dialog box remebering him to save the changes or leaving the view without saving (changes will be lost).
I tried at first to put a boolean "inputChanged" on my Bean, then setting it to true with an adapted event (onchange) by each component. And by the buttons/links which link to another page I tried to show a <rich:modalpanel> once the value of "inputChanged" is true but I couldn't realize this conditions.
Thereafter I found a solution based on Javascript:
<script language="javascript" type="text/javascript">
    // Keep flag when something had changed
    var changed = false;
    Save in "changed" flag, whether an input had been done by the user.
    after that the calling of this method will be removed
    from the corresponding attribute of the input elements,
    in order to avoid redundant method calls */
    function storeChange(aChanged, aElement) {
        changed = aChanged;
        aElement.setAttribute('onchange', '');
    Finally and when the "changed" flag is true, a confirmation message will be shown
    to confirm whether the page could be left.  
    window.onbeforeunload=function unloadAlert() {
        if(changed) {
            return 'You have unsaved changes on the page. If you click on OK, the changes will be lost';
        return null;
</script>{code}
And in the view:
{code}<a4j:form>
        <h:outputLabel id="label_name" value="Name" for="in_name" />
        <h:inputText id="in_name" value="#{bean.name}"
            onchange="storeChange(true, this)" />
        <br />
        <h:outputLabel id="label_email" value="E-Mail" for="in_email" />
        <h:inputText id="in_email" value="#{bean.email}"
            onchange="storeChange(true, this)" />
        <br />
        <a4j:commandButton oncomplete="javascript:changed=false"
            value="Save" />
    </a4j:form>{code}
And now I'd
like rather than the JS terriying dialog box, a user-friendly rich:modalPanel which should do the same function.
For any
indication I will be very very thankful                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Hi David,
Thank for the prompt answer. I've tried that before but I have put that in checkin action. So that didn't work before but now as per your suggestion it works nicely. The form isn't evaluated.
However, this time my changes aren't reflected on the user.. Basically what I do is
- checkout user view (with empty form) (in an activity)
- update user view (in another activity)
- check in user view (in another activity)
however, changes are discarded. I used winmerge to compare and saw exactly the necessary fields are updated after update activity. but after checkin no changes are reflected. so what should I do now :(
Relevant actions are:
<Action id='0' application='com.waveset.session.WorkflowServices'>
          <Argument name='op' value='checkoutView'/>
          <Argument name='viewId'>
            <concat>
              <s>User:</s>
              <ref>accountId</ref>
            </concat>
          </Argument>
          <Argument name='type' value='User'/>
          <Argument name='id' value='$(accountId)'/>
          <Argument name='Form' value='Empty Form' />
          <Return from='view' to='user'/>
          <Return from='WF_ACTION_ERROR' to='error'/>
        </Action>
        <Action id='0' application='com.waveset.session.WorkflowServices'>
          <Argument name='op' value='checkinView'/>
          <Argument name='view' value='$(user)'/>
          <Return from='WF_ACTION_ERROR' to='error'/>
        </Action>

Similar Messages

  • How to update views with new changes

    Hi Experts
      I had 3 views created on a Query,Which(views) are being used in Dashboard reports.
      Now as per my requirment i need to update my Query with few new chars and some user enty variables.
      How can i update my views....with new changes
    Thanks

    Hi developerbw,
    Here are steps you can do to make the change
    1. open your old view
    2. make the change
    3. save the view uing the same description and technical name, (Make sure you you say yes when it ask whether to overwrite the exisitng view)
    no need to create new views
    feng

  • Create a view with a changing where clause

    Hi all,
    i'm developing an application with oracle forms i want to create a view in the database with a different where clause in every time , the where clause is determined due to the department id of the current user .
    thanks alot.

    SQL> create view emp_view as select empno, ename, deptno from emp;
    View created.
    SQL> select * from emp_view where deptno = 10;
         EMPNO ENAME          DEPTNO
          7782 CLARK              10
          7839 KING               10
          7934 MILLER             10
    SQL>

  • How to popup confirm dialog trying to navigate away with unsaved changes

    Is there any generic or built-in solutions for this common requirement?
    JDev: 11g
    any idea or material on this is appreciated.
    Thanks.
    Kevin.

    try capturing the onBeforeUnload event and display a modal confirmation dialog asking the user if he really wants to navigate away from the page; and warning him that if he does so, all the changes he made hitherto will be gone.
    However, you need to handle this intelligently since you need to identify if any fields in the form have changed and only then warn the user to confirm his decision to go away from this page.
    You can do this by having a flag which is initialized to false but when onBeforeUnload event is fired, you would check if any of the form fields in the page have changed by iterating over each and every form field,and then setting the flag to true if some thing changed
    the onBeforeUnload Handler will always return this flag, if it is true, you will get this confirmation popup, else the page will go away. To show a customized confirmation dialog, perhaps you would have to invoke the custom dialog call from with in the onBeforeUnload handler. When the user says yes, return false;else true.

  • JDev 11.1.1.2.0: Problem with refresh in form view after delete

    Hi All,
    I'm trying to delete the current row in a form view with the delete binding operation and obviously I do NOT want to fire any validations so I use the immediate = true but that causes the ADF lifecycle to skip the update models phase and thus my fields are not refreshed with the new current row after the old row has been deleted.
    How can I fix this ?
    Thanks in advance,
    Mark

    First the standard disclaimer: SQL code should be in a servlet/bean. It has no place on a JSP.
    I would recommend you write a bean method that returns a list of objects, and then iterate over that list of objects on the JSP.
    What exception does is getting thrown?
    At a guess, your problem is that you are not releasing all resources. Connections, statements, resultsets...
    That is probably hidden inside your DBBean. You are maybe releasing your result set with the statement Rset.close() - but if an exception happens even that wouldn't be executed.
    Any sql code should be in a try/catch block, with resources being freed in the finally.
    Cheers,
    evnafets

  • Insert form view data into table view

    Hi Experts,
      I have
                 --> a form view with three input fields and a button(ADD)
                 --> a table view with three columns.
    Both views in same page.
    My requirement is when a user enters the three inputs and click button (ADD) all the inputs entered should be inserted in the below table view.
    User can be able to enter multiple lines by clicking ADD again and again with different inputs.
    How to insert rows from a form view event (ADD) into table view?
    Thanks&Regards,
    karthik

    Hi
    Which 'System Action' are you using in the 'Add' button? You need to use 'Insert Row' Action. When you select this below the action you will get one box 'Apply To' there you select the table. Then save & deploy the model, you will get what you want.
    Caution - THis data will not get stored in the table permenently, once you close this model you will loose all the data.
    Regards
    Sandeep

  • FM8: File Always Opens Unsaved Changes

    Hi,
    I have a file in Framemaker 8 that always opens with "unsaved changes."  I save the file, the asterisk clears, but the next time I open the file the asterisk is there.
    I thought this might be a "missing font" issue and, as a test, turned off Remember missing fonts. This setting does not seem to impact this behavior.
    Any help much appreciated.
    Mary

    I found a very nice explanation by Fred Ridder on Framers:
    I think a better understanding of how cross-references are handled will help you under why I say this.
    Whenever you open a file that contains one or more cross-references, FrameMaker refreshes each of those references. If the reference is to another location within the same file, the refresh is straightforward unless the cross-reference truly is unresolved due to a missing or hidden cross-reference marker. If the reference points to a location that is in another file that is already open, the process is similarly straightforward.
    But if the reference points to a location that is in a file that is *not* already open, FrameMaker has to silently (without showing anything on your screen) peek inside the target file to retrieve the latest information for the refernce. If that file has any sort of problem that would throw a warning message during a non-silent open (e.g. an unavailable fonts message), FrameMaker is unable to peek inside it and therefore cannot find the marker it's looking for. It reports this failure to find the marker as an unresolved cross-reference. If you start by manually opening the file with the missing fonts issue, so that you can manually dismiss the warning message, then you will not get an unresolved cross-reference warnign when you open the original file because FrameMaker can now find the target marker when it updates the cross-references.
    BTW, the updating of the cross-references is the reason why FrameMaker will warn you about unsaved changes when you attempt to close a file that you *know* you didn't make any edits in. Even if the cross-references did not actually change as a result of the update operation, the fact that they were refreshed counts as a change that FrameMaker thinks you ought to save.
    -Fred Ridder
    This  makes sense and matches with what you said so succinctly Jeff. Thanks for the help.
    Mary

  • Why does this occur "NI_Variable_RT.lvlib : GlobalVar_RT_MangleName.vi has unsaved changes?"

    I am trying to deploy a VI to the RT target and I get this message.
    "NI_Variable_RT.lvlib : GlobalVar_RT_MangleName.vi has unsaved changes"
    I am only allowed to deploy the VI if I save these changes. What are these changes referring to?
    Has the link between the variables on the Host PC and RT target broken due to which this message occurs?

    Hi Shan21,
    Do you not get an option to view the unsaved changes? If you want to find out the changes that have taken place in a VI, here is a description. If you navigate and open the VI and then go File->VI Properties. Under the General tab there is a button marked List unsaved changes. This will show you the changes that have taken place. 
    If you have made no changes that you are aware of to this VI, it maybe that you are converting it from a previous version to the most current version.
    Thanks,
    Andrew McLennan
    Applications Engineer
    National Instruments

  • Mail with leave notification form

    hi experts!!
            could anyone pl tel me  how to send a mail with leave notification form.Thanks in advacne!!!
    Edited by: Ranganayahi Chandirasekaran on Apr 11, 2008 11:34 AM

    Hi,
        Leave notification for this u can check this site,
    http://help.sap.com/saphelp_nw04/helpdata/en/e6/56a038d14a2571e10000009b38f8cf/frameset.htm

  • Why can't I view responses and form shared with me anymore?

    Someone shared a form with me, made me a co-author, and I was tweaking the form and getting responses on Adobe Forms Central with a user id that begins with swm.  I bought Adobe Pro using a different user id and had problems getting my educational discount done.  After 2 weeks of back and forth, the customer service people did eventually make it so that I have one user id, swm and a free adobe forms central account and a paid educational Adobe Pro account.  I spent over 3 hours on the phone with adobe today over two calls trying to get this finalized today.  However, NOW when I log into adobeforms central it tells me I don't have access to that document or permission to view it anymore even though I am using the same email, which is my adobe id.  
    Do I have to get the person who originally shared it with me to do something, or can I do it myself or with the help of adobe customer service?  I do NOT want to bother the person that shared it with me if it's possible because the school will have to PAY that person!  Please help! 

    I apologize for the problems you have had with your education discount.
    If you send me via email ([email protected]) the document ID of the form you are trying to access as well as the email address you are using to log in I can check on my side why you don't have access to the form anymore.
    You can find the document ID in the link of the HTML form. It is the 22-charaters string follorwing "https://adobeformscentral.com/?f="
    Gen

  • How do you associate a view with a form?

    How do you associate a view with a form and make it accessible in the form?

    Try this
      <Field name='myview'>
                        <Display class='Text'>    
                            <Property name='title' value='My View'/>
                        </Display>
                        <Derivation>                       
                            <invoke name='getView'>
                                <ref>:display.session</ref>
                                <concat>
                                    <s>User:</s>
                                    <ref>accountId</ref>
                                </concat>                       
                                <map>
                                    <s>authorized</s>
                                    <s>true</s>
                                </map>
                            </invoke>
                        </Derivation>
                    </Field>           
                    <Field name='myview.waveset.organization'>
                        <Display class='Text'>    
                            <Property name='title' value='User Org'/>
                        </Display> 
                    </Field>

  • I'm in the military. Is Mac compatible with Lotus Forms viewer, Silanis ApproveIT and Activeclient for CAC?

    I'm in the military and I'm thinking about buying a Mac. I will need to install a CAC reader, Lotus Forms viewer, Silanis ApproveIT and ActiveClient. Can this be done and is it relatively painless to do?

    IBM made some software to view those forms on a Mac, but I don't know if it still exists. It was quite flakey, also. edit: Sounds like from militarycac.com that it no longer exists.
    See MilitaryCAC.com, specifically the Lion page, for info on using a CAC with the MAC. You need to purchase a compatible card reader, which they discuss there.
    It seems the easiest method is to use Thursby's PKard for Mac ($30 at www.thursby.com), but there are free alternatives. ActiveClient is not used at all. It is Windows only.

  • Warning on Unsaved Changes Functional Pattern

    Overview
    One advantage of integrated applications is users can easily navigate just about anywhere based on current needs. However, with the added flexibility also comes the increased risk of unsaved data accidentally being lost when navigating away from a page. Therefore, many applications typically warn the user when this is about to occur. Using the new warning on unsaved changes feature, 11g ADF applications can easily implement this type of functionality.
    Click here to see the document that describes this pattern.
    Edited by: Richard Wright on May 13, 2010 1:10 PM

    Hi,
    I have a page with an edit form. The user can close/leave the page by clicking on different buttons (menu items, close icon, back button). In this case, the system should warn the user about unsaved data. Furthemore, I want to skip data validation. I tried to implement the "Warning on Unsaved Changes Functional UI Pattern", although this approach doesn't skip data validation. How should I do this?
    I'm using ADF 11g.
    Pedro Medeiros.

  • Updating a report source/viewer with new filename

    I posted earlier about this problem but now can be more specific so thought a re-post was in order. I am trying to setup an asp.net website using .NET 2.0 and Crystal Reports 2008. Rather than having a seperate page for each possible report with a viewer on it I decided to setup a page and pass it session variables telling it what file name to set the report source to and the variables to pass to it. This worked fine in crystal reports basic (the one with visual studio).
    So I have on the page CrystalViewer (CrystalReportViewer) with display page true seperate pages true and crystalRepSource (CrystalReportSource) with cache enabled and viewstate enabled as far as I know cache is required for the paging to work.
    In my form code behind file i have something like:
    protected void Page_Load(object sender, EventArgs e) {
    CrystalRepSource.Report.FileName = SessionHandler.RunReport;
    switch (report)
    if (PreviousPage != null || paramHasChanged)
    case @"~\CollegeReports\CR_Course_Review.rpt":
                    //setup report in viewer with correct db logon
                    SetupLogonInfo(CrystalRepSource);
                    //add parameters
                    CrystalRepSource.ReportDocument.SetParameterValue("@year", year);
                    CrystalRepSource.ReportDocument.SetParameterValue("@school", school);
                    CrystalRepSource.ReportDocument.SetParameterValue("@division", division);
                    CrystalRepSource.ReportDocument.SetParameterValue("@progArea", progArea);
                    CrystalRepSource.ReportDocument.SetParameterValue("@type", SessionHandler.record_type);
                    CrystalRepSource.ReportDocument.SetParameterValue("@filterText", "School = \'" + school +
                                                            "\' Division = \'" + division
                                                            + "\' Programme Area = \'" + progArea
                                                            + "\' Record Type = \'" + SessionHandler.record_type_text + "\'");
                    break;
                case @"~\CollegeReports\CR_WBL_Attendance_Sheets.rpt":
                    //setup report in viewer with correct db logon
                    SetupLogonInfo(CrystalRepSource);
                    //add parameters
                    CrystalRepSource.ReportDocument.SetParameterValue("@year", year);
                    CrystalRepSource.ReportDocument.SetParameterValue("@school", school);
                    CrystalRepSource.ReportDocument.SetParameterValue("@division", division);
                    CrystalRepSource.ReportDocument.SetParameterValue("@progArea", progArea);
                    CrystalRepSource.ReportDocument.SetParameterValue("@attendanceEndDate", LastDayOfMonth(SessionHandler.WBL_EndDate).ToString());
                    break;
    The case statement actually has about 20 reports in it it is basically used to send the appropriate parameter set to the report and setup the database logon info, the if statement around the case checks if the load is a postback (to allow paging of the report) if it is it won't run the code or if a parameter has changed if one has it will rerun the code. As I said this worked in CR basic.
    Unfortunately what now seems to happen is the first time I run a report it works fine, if I then leave the page and run a report requiring different parameters it will give me the parameter error. However if instead I run a report requiring the same parameters it will show the original report document as if it is coming from cache I think. The case becomes a bit more bizarre later as I have created the ability to change a parameter without leaving the report page this actually does a postback and changes the report to the proper one with the proper data.
    So it seems to me the code to change report is working first time and for postback but not for re-entering the page. I am really stuck been working on this for hours  any ideas.

    ok i have found the solution after a quite a while so anyone else getting this I was using the line:
    CrystalRepSource.Report.FileName = SessionHandler.RunReport;
    I changed it to:
    CrystalRepSource.ReportDocument.Load(Server.MapPath(ReportName));
    This clears any existing report and loads the correct one seems to have solved all my problems.

  • David Powers --- Regarding form validation with dreamweaver behaviors

    I am in the chapter teaching about form validation with the Zend Framework. I have done the entire lesson with the lesson files and everything works perfectly...
    but I went back to use the form valdation techniques for my own site and it is not working properly. In the book, Chapter 6 teaches how to create a user login and editing the database through the site. But in chapter seven the form validation does not build on top of this and therefore does not teach how to integrate the form validation with the registered user already set up.
    I have user registration completly working on my site and everything runs fine. I am trying to add the form validation but it is all completly ignored. When I leave a field blank it simply takes me to another blank page that reads "Column 'first_name' cannot be null"
    here is index.php code...
    <?php require_once('Connections/CSSU_Write.php'); ?>
    <?php require_once('Connections/CSSU_Read.php'); ?>
    <?php require_once('script/user_registration.php');
    ?>
    <?php
    if (isset($_POST['password'])) {
              $_POST['password'] = sha1($_POST['password']);
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO sign_up (first_name, family_name, user_email, password, gender, bday_month, bday_day, bday_year) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['first_name'], "text"),
                           GetSQLValueString($_POST['last_name'], "text"),
                           GetSQLValueString($_POST['email'], "text"),
                           GetSQLValueString($_POST['password'], "text"),
                           GetSQLValueString($_POST['gender'], "text"),
                           GetSQLValueString($_POST['bday_month'], "text"),
                           GetSQLValueString($_POST['bday_day'], "text"),
                           GetSQLValueString($_POST['bday_year'], "text"));
      mysql_select_db($database_CSSU_Write, $CSSU_Write);
      $Result1 = mysql_query($insertSQL, $CSSU_Write) or die(mysql_error());
      $insertGoTo = "login.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['email'])) {
      $loginUsername=$_POST['email'];
      $password=$_POST['password'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "logoOutRedirect.php";
      $MM_redirectLoginFailed = "logoOutRedirect.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_CSSU_Write, $CSSU_Write);
      $LoginRS__query=sprintf("SELECT user_email, password FROM sign_up WHERE user_email=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $CSSU_Write) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
              if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;               
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
        header("Location: " . $MM_redirectLoginSuccess );
      else {
        header("Location: ". $MM_redirectLoginFailed );
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>CSSU</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div class="container">
      <div class="header">
      <div class="logo">
                <a href="index.php">
                  <h1/>
            .CSSU { UNIVERSITY; }
            </h1>
            <h2>
            <code><<code>!</code>-- Learn/Apply/Master --></code>
            </h2>
        </a>
      </div> 
        <!-- end .header --></div>
        <div class="headerBar">
        <div id="nav">
                  <ul id="links">
                      <a href="#"><li>CSSU</li></a>
                      <a href="#"><li>Classes</li></a>
                      <a href="#"><li>Pricing</li></a>
                      <a href="#"><li>Degree</li></a>
                  </ul>
        </div>
        <form name="form2" method="POST" action="<?php echo $loginFormAction; ?>" class="form2">
        <p>
            <label for="email" id="email" class="loginLabel">Email:</label>
            <input type="email" name="email" class="loginField" />
            <label for="password" id="password" class="loginLabel">Password:</label>
            <input type="password" name="password" class="loginField" />
                  <input type="submit" value="Log In" name="submit" class="submit login" />
        </p>
        </form>
        </div>
      <div class="container2">
      <div class="sidebar1">
        <h1>Sign Up</h1>
        <h2>Earn an Official CSS Masters Certification!</h2>
        <table>
        <form name="form1" method="POST" action="<?php echo $editFormAction; ?>" class="form1">
        <tr >
            <td class="formLabel"><label for="firstName" id="firstNameLabel" >First Name:</label>
                      <span>
                         <?php
                                  if ($_POST && isset($errors['first_name'])) {
                                            echo $errors['first_name'];
                                  ?>
                </span>
            </td>
            <td><input type="text" name="first_name" class="inputField" id="firstName" /></td>
        </tr>
        <tr>
            <td class="formLabel"><label for="lastName" id="lastName" >Last Name:</label></td>
            <td><input type="text" name="last_name" class="inputField" /></td>
        </tr>
        <tr>
            <td class="formLabel"><label for="yourEmail" id="yourEmail" >Your Email:</label></td>
            <td><input type="user_email" name="email" class="inputField" /></td>
        </tr>
        <tr>
            <td class="formLabel"><label for="yourEmail2" id="yourEmail2">Re-enter Email:</label></td>
            <td><input type="email" name="reEnter_email" class="inputField" /></td>
        </tr>
        <tr>
            <td class="formLabel"><label for="password" id="password">New Password:</label></td>
            <td><input type="password" name="password" class="inputField" /></td>
        </tr>   
        <tr>
            <td class="formLabel"><label for="gender" id="gender" class="formLabel">I am:</label></td>
          <td><select name="gender" class="selectMenu selectMenu1 gender">
              <option value="select">Select Sex:</option>
              <option value="male" name="male">Male</option>
              <option value="female" name="female">Female</option>
                        </select>
          </td>
              </tr>
               <tr>
            <td class="formLabel"><label for="bday">Birthday:</label></td>
               <td>
            <select name="bday_month" class="selectMenu selectMenu1 bday">
              <option value="male">Month:</option>
              <option value="January">January</option>
            </select>
    <select name="bday_day" class="selectMenu bday">
              <option value="Day">Day:</option>
              <option value="1">1</option>
                        </select>
    <select name="bday_year" class="selectMenu bday">
              <option value="Year">Year:</option>
            </select>
         </td>
        </tr>
        <tr>
                  <td class="submitTd" colspan="2"><input type="submit" value="Sign Up" name="submit" class="submit signup" /><td>
        </tr>
        <input type="hidden" name="MM_insert" value="form1" />
        </form>
        </table>
        <!-- end .sidebar1 --></div>
      <div class="content">
        <h1>CSSU</h1>
        <!-- end .content --></div>
      <div class="footer">
        <!-- end .footer --></div>
        </div> <!-- end container2 -->
      <!-- end .container --></div>
    </body>
    </html>
    And here is user_registration.php code just for the first_name field...
    <?php
    $errors = array();
    if ($_POST) {
      // run the validation script
      require_once('library.php');
      try {
              // main script goes here
              $val = new Zend_Validate_Regex('/^[a-z]+[-\'a-z ]+$/i');
              if (!$val->isValid($_POST['first_name'])) {
                $errors['first_name'] = 'Required field, no numbers';
      } catch (Exception $e) {
              echo $e->getMessage();
    And from here, here is the library.php code....
    <?php
    $library = '.../html/zend/library';
    set_include_path(get_include_path() . PATH_SEPARATOR . $library);
    require_once('Zend/Loader/Autoloader.php');
    try {
    Zend_Loader_Autoloader::getInstance();
      $write = array('host'     => 'hostname',
                                             'username' => 'cssu',
                                             'password' => 'password',
                                             'dbname'   => 'cssu');
      $read  = array('host'     => 'hostname',
                                             'username' => 'cssu',
                                             'password' => 'password',
                                             'dbname'   => 'cssu');
      // Comment out the next two lines if using mysqli
      // and remove the comments from the last two lines
      $dbWrite = new Zend_Db_Adapter_Pdo_Mysql($write);
      $dbRead = new Zend_Db_Adapter_Pdo_Mysql($read);
      //$dbWrite = new Zend_Db_Adapter_Mysqli($write);
      //$dbRead = new Zend_Db_Adapter_Mysqli($read);
    } catch (Exception $e) {
              echo $e->getMessage();
    I replaced some code here to protect myself, but the library.php file is completely functional and has been tested... I am sure the problem ins't in here.
    Please let me know if you need any further code to help you out. I am brand new to PHP and so far everything has ran smoothly up til now. I have my Zend Framework uploaded to my server and tested that my site is connecting to it properly. Any help on this would be so so awesome! This is for a school project and I can't move on until this is resolved! Thank you so much for trying!
    You can also view the issue at my website... all the files have been uploaded to the server. www.CSSU.com

    I am in the chapter teaching about form validation with the Zend Framework. I have done the entire lesson with the lesson files and everything works perfectly...
    but I went back to use the form valdation techniques for my own site and it is not working properly. In the book, Chapter 6 teaches how to create a user login and editing the database through the site. But in chapter seven the form validation does not build on top of this and therefore does not teach how to integrate the form validation with the registered user already set up.
    I have user registration completly working on my site and everything runs fine. I am trying to add the form validation but it is all completly ignored. When I leave a field blank it simply takes me to another blank page that reads "Column 'first_name' cannot be null"
    here is index.php code...
    <?php require_once('Connections/CSSU_Write.php'); ?>
    <?php require_once('Connections/CSSU_Read.php'); ?>
    <?php require_once('script/user_registration.php');
    ?>
    <?php
    if (isset($_POST['password'])) {
              $_POST['password'] = sha1($_POST['password']);
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO sign_up (first_name, family_name, user_email, password, gender, bday_month, bday_day, bday_year) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['first_name'], "text"),
                           GetSQLValueString($_POST['last_name'], "text"),
                           GetSQLValueString($_POST['email'], "text"),
                           GetSQLValueString($_POST['password'], "text"),
                           GetSQLValueString($_POST['gender'], "text"),
                           GetSQLValueString($_POST['bday_month'], "text"),
                           GetSQLValueString($_POST['bday_day'], "text"),
                           GetSQLValueString($_POST['bday_year'], "text"));
      mysql_select_db($database_CSSU_Write, $CSSU_Write);
      $Result1 = mysql_query($insertSQL, $CSSU_Write) or die(mysql_error());
      $insertGoTo = "login.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['email'])) {
      $loginUsername=$_POST['email'];
      $password=$_POST['password'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "logoOutRedirect.php";
      $MM_redirectLoginFailed = "logoOutRedirect.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_CSSU_Write, $CSSU_Write);
      $LoginRS__query=sprintf("SELECT user_email, password FROM sign_up WHERE user_email=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $CSSU_Write) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
              if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;               
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
        header("Location: " . $MM_redirectLoginSuccess );
      else {
        header("Location: ". $MM_redirectLoginFailed );
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>CSSU</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div class="container">
      <div class="header">
      <div class="logo">
                <a href="index.php">
                  <h1/>
            .CSSU { UNIVERSITY; }
            </h1>
            <h2>
            <code><<code>!</code>-- Learn/Apply/Master --></code>
            </h2>
        </a>
      </div> 
        <!-- end .header --></div>
        <div class="headerBar">
        <div id="nav">
                  <ul id="links">
                      <a href="#"><li>CSSU</li></a>
                      <a href="#"><li>Classes</li></a>
                      <a href="#"><li>Pricing</li></a>
                      <a href="#"><li>Degree</li></a>
                  </ul>
        </div>
        <form name="form2" method="POST" action="<?php echo $loginFormAction; ?>" class="form2">
        <p>
            <label for="email" id="email" class="loginLabel">Email:</label>
            <input type="email" name="email" class="loginField" />
            <label for="password" id="password" class="loginLabel">Password:</label>
            <input type="password" name="password" class="loginField" />
                  <input type="submit" value="Log In" name="submit" class="submit login" />
        </p>
        </form>
        </div>
      <div class="container2">
      <div class="sidebar1">
        <h1>Sign Up</h1>
        <h2>Earn an Official CSS Masters Certification!</h2>
        <table>
        <form name="form1" method="POST" action="<?php echo $editFormAction; ?>" class="form1">
        <tr >
            <td class="formLabel"><label for="firstName" id="firstNameLabel" >First Name:</label>
                      <span>
                         <?php
                                  if ($_POST && isset($errors['first_name'])) {
                                            echo $errors['first_name'];
                                  ?>
                </span>
            </td>
            <td><input type="text" name="first_name" class="inputField" id="firstName" /></td>
        </tr>
        <tr>
            <td class="formLabel"><label for="lastName" id="lastName" >Last Name:</label></td>
            <td><input type="text" name="last_name" class="inputField" /></td>
        </tr>
        <tr>
            <td class="formLabel"><label for="yourEmail" id="yourEmail" >Your Email:</label></td>
            <td><input type="user_email" name="email" class="inputField" /></td>
        </tr>
        <tr>
            <td class="formLabel"><label for="yourEmail2" id="yourEmail2">Re-enter Email:</label></td>
            <td><input type="email" name="reEnter_email" class="inputField" /></td>
        </tr>
        <tr>
            <td class="formLabel"><label for="password" id="password">New Password:</label></td>
            <td><input type="password" name="password" class="inputField" /></td>
        </tr>   
        <tr>
            <td class="formLabel"><label for="gender" id="gender" class="formLabel">I am:</label></td>
          <td><select name="gender" class="selectMenu selectMenu1 gender">
              <option value="select">Select Sex:</option>
              <option value="male" name="male">Male</option>
              <option value="female" name="female">Female</option>
                        </select>
          </td>
              </tr>
               <tr>
            <td class="formLabel"><label for="bday">Birthday:</label></td>
               <td>
            <select name="bday_month" class="selectMenu selectMenu1 bday">
              <option value="male">Month:</option>
              <option value="January">January</option>
            </select>
    <select name="bday_day" class="selectMenu bday">
              <option value="Day">Day:</option>
              <option value="1">1</option>
                        </select>
    <select name="bday_year" class="selectMenu bday">
              <option value="Year">Year:</option>
            </select>
         </td>
        </tr>
        <tr>
                  <td class="submitTd" colspan="2"><input type="submit" value="Sign Up" name="submit" class="submit signup" /><td>
        </tr>
        <input type="hidden" name="MM_insert" value="form1" />
        </form>
        </table>
        <!-- end .sidebar1 --></div>
      <div class="content">
        <h1>CSSU</h1>
        <!-- end .content --></div>
      <div class="footer">
        <!-- end .footer --></div>
        </div> <!-- end container2 -->
      <!-- end .container --></div>
    </body>
    </html>
    And here is user_registration.php code just for the first_name field...
    <?php
    $errors = array();
    if ($_POST) {
      // run the validation script
      require_once('library.php');
      try {
              // main script goes here
              $val = new Zend_Validate_Regex('/^[a-z]+[-\'a-z ]+$/i');
              if (!$val->isValid($_POST['first_name'])) {
                $errors['first_name'] = 'Required field, no numbers';
      } catch (Exception $e) {
              echo $e->getMessage();
    And from here, here is the library.php code....
    <?php
    $library = '.../html/zend/library';
    set_include_path(get_include_path() . PATH_SEPARATOR . $library);
    require_once('Zend/Loader/Autoloader.php');
    try {
    Zend_Loader_Autoloader::getInstance();
      $write = array('host'     => 'hostname',
                                             'username' => 'cssu',
                                             'password' => 'password',
                                             'dbname'   => 'cssu');
      $read  = array('host'     => 'hostname',
                                             'username' => 'cssu',
                                             'password' => 'password',
                                             'dbname'   => 'cssu');
      // Comment out the next two lines if using mysqli
      // and remove the comments from the last two lines
      $dbWrite = new Zend_Db_Adapter_Pdo_Mysql($write);
      $dbRead = new Zend_Db_Adapter_Pdo_Mysql($read);
      //$dbWrite = new Zend_Db_Adapter_Mysqli($write);
      //$dbRead = new Zend_Db_Adapter_Mysqli($read);
    } catch (Exception $e) {
              echo $e->getMessage();
    I replaced some code here to protect myself, but the library.php file is completely functional and has been tested... I am sure the problem ins't in here.
    Please let me know if you need any further code to help you out. I am brand new to PHP and so far everything has ran smoothly up til now. I have my Zend Framework uploaded to my server and tested that my site is connecting to it properly. Any help on this would be so so awesome! This is for a school project and I can't move on until this is resolved! Thank you so much for trying!
    You can also view the issue at my website... all the files have been uploaded to the server. www.CSSU.com

Maybe you are looking for

  • A continuing POP e-mail issue (Web OS)

    I have an issue with a attglobal.net e-mail account that I have not seen posted. I can only download one e-mail at a time, and the only way I can get the next e-mail is to delete the message I just downloaded. Sometimes it takes up to three hours bef

  • Error while subscription on SSRS report that uses custom assembly

    I am new to SSRS. i have created a report that uses custom assembly that runs an oracle procedure and bring back result to report. this works fine on sharepoint mode interactive report. while i subscribe the same report, i am getting below error Requ

  • ILife '08 Gone?!

    I just got my MacBook Pro like on the 26th and it totally messed up or something, so I went to The Apple Store and had a Genius help me out. He told me that Leopard had to be reinstalled and he did it and now everything's working the way it's suppose

  • Recipient unable to open Acrobat 9 form with Adobe Reader 9

    Over the past 8 months I have distributed a form created in Acrobat 9 Pro to over 50 recipients. Most of them have been able to open and complete the form sucessfully. In the past two weeks I've sent the same form to two new receipients and they both

  • How can I determine how many days are left on an evaluation Enterprise license key?

    I am using the evaluation key available for SP 2010 enterprise. However, I would like to be able to determine how many days remain before it expires. Is there a page/link/powershell command/etc. for getting that information? Thank you.